Cài đặt brew(trang chủ brew) (đã cài rồi thì bỏ qua)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Sau khi cài lệnh này ở cuối nó sẽ có next steps, có 2 dòng lệnh, copy lại và run. Rồi cài tiếp các lệnh sau:
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
Run tiếp:
sudo apt-get install build-essential procps curl file git
Xong, chạy thử:
brew install hello
Cài mkcert (trang chủ mkcert)
sudo apt install libnss3-tools
brew install mkcert
Tạo mkcert
mkcert -install
Tạo certificate cho các tên miền, (ví dụ ở đây tạo cho: example.com *.example.com example.test localhost 127.0.0.1 ::1)
mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1
Sau khi run lệnh trên sẽ trả về vị trí của 2 file domain.pem và domain-key.pem (trường hợp của tôi nằm ở /home/<username>/)
Thêm vào Apache
Thêm đoạn sau vào file /etc/apache2/sites-available/<domain>.conf
Nếu chưa cài Apache Virtual Host, có thể xem tại đây.
<VirtualHost 127.0.0.1:443>
ServerAdmin webmaster@<domain>
DocumentRoot /var/www/html/<project>/
ServerName <domain>
SSLEngine on
SSLCertificateFile /home/<username>/domain.pem
SSLCertificateKeyFile /home/<username>/domain-key.pem
<Directory /var/www/html/<project>/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Chạy lại apache
sudo a2enmod ssl
sudo a2enmod rewrite
sudo systemctl reload apache2
sudo systemctl restart apache2
Xong, vào lại domain đã tạo xem url chuyển thành https chưa.
Không có nhận xét nào:
Đăng nhận xét