Server 重置具有let';s已安装加密ssl证书
我有一个网站Server 重置具有let';s已安装加密ssl证书,server,apache2,lets-encrypt,Server,Apache2,Lets Encrypt,我有一个网站www.example.com,它位于/var/www/example.com目录下的apache2 web服务器上,虚拟主机配置文件是 <VirtualHost *:80> ServerAdmin admin@gmail.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public <Direct
www.example.com
,它位于/var/www/example.com
目录下的apache2 web服务器上,虚拟主机配置文件是
<VirtualHost *:80>
ServerAdmin admin@gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public
<Directory /var/www/example.com/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
服务器管理员admin@gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot/var/www/example.com/public
选项索引跟随符号链接
允许超越所有
要求所有授权
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
DirectoryIndex.php index.pl index.cgi index.html index.xhtml>
我已经为这个域安装了let's encrypt证书
现在我必须更改配置设置,配置文件应如下所示:
<VirtualHost *:80>
ServerAdmin admin@gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/dist //here is the change
<Directory /var/www/example.com/dist/> //here is the change
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
服务器管理员admin@gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot/var/www/example.com/dist//
//找零
选项索引跟随符号链接
允许超越所有
要求所有授权
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
DirectoryIndex.php index.pl index.cgi index.html index.xhtml>
我已经编辑了配置文件并运行了命令certbot--apache-d example.com-d www.example.com
。
选择了重新安装
和续订
两个选项,两种情况下安装都成功。但当我进入example.com
时,它会显示404错误
。
如何解决我的问题?HTTPS使用端口443,而不是端口80。端口443已关闭。您需要添加一个新的虚拟主机来处理HTTPS请求
<VirtualHost *:443>
ServerName example.com
#ServerAlias www.example.com
ServerAdmin admin@gmail.com
DocumentRoot /var/www/example.com/dist
LogLevel debug ssl:info
SSLEngine on
SSLCertificateFile /path/to/yout/cert
SSLCertificateKeyFile //path/to/yout/key
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
启用SSL模块时,Apache2将打开端口443。因此,请记住跑步:
sudo a2dismod ssl
sudo systemctl restart apache2
HTTPS使用端口443,而不是端口80。
sudo a2dismod ssl
sudo systemctl restart apache2