借一步网
作者:
在
要在Apache2上启用HTTPS,您需要完成以下步骤:
sudo apt install apache2
sudo yum install httpd
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
sudo a2enmod ssl
sudo nano /etc/apache2/sites-available/default-ssl.conf
sudo nano /etc/httpd/conf.d/ssl.conf
<VirtualHost _default_:443> ServerAdmin your_email@example.com DocumentRoot /var/www/html ServerName your_domain.com SSLEngine on SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo a2ensite default-ssl.conf
sudo systemctl reload apache2
sudo systemctl reload httpd
sudo ufw allow 'Apache Full'
sudo firewall-cmd --permanent --add-service=https
sudo ufw reload
sudo firewall-cmd --reload
现在,您的Apache2服务器已经配置为使用HTTPS。您可以通过访问https://your_domain.com来测试它。
https://your_domain.com
Learn more:
要发表评论,您必须先登录。
要在Apache2上启用HTTPS,您需要完成以下步骤:
sudo apt install apache2
sudo yum install httpd
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
sudo a2enmod ssl
sudo nano /etc/apache2/sites-available/default-ssl.conf
sudo nano /etc/httpd/conf.d/ssl.conf
<VirtualHost _default_:443> ServerAdmin your_email@example.com DocumentRoot /var/www/html ServerName your_domain.com SSLEngine on SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo a2ensite default-ssl.conf
sudo systemctl reload apache2
sudo systemctl reload httpd
sudo ufw allow 'Apache Full'
sudo firewall-cmd --permanent --add-service=https
sudo ufw reload
sudo firewall-cmd --reload
现在,您的Apache2服务器已经配置为使用HTTPS。您可以通过访问
https://your_domain.com
来测试它。Learn more: