我为运行apache 的Amazon linux服务器添加了一个新域
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/mydomain
ErrorDocument 404 /index.html
ErrorLog /var/log/mydomain.com-error_log
CustomLog /var/log/mydomain.com-access_log common
<Directory /var/www/mydomain>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
已重新启动服务器已检查状态sudo systemctl restart httpd
激活(运行(1分钟但无论出于何种原因,都会提供默认的apacheindex.html目录为新域存在,index.html有chmod 644完成
新域的错误日志为空。访问日志和错误日志为空
-rw-r--r--. 1 root root 0 Dec 21 15:26 mydomain.com-access_log
-rw-r--r--. 1 root root 0 Dec 21 09:50 mydomain.com-error_log
主机尾部error_log为正常
AH00489: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1c configured -- resuming normal operations
[Mon Dec 21 15:02:24.161922 2020] [core:notice] [pid 73594:tid 140519198484800]
AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
我觉得权限/证书有问题。或者还有一件事letsencrypt-crt已经为新域安装,可能成功
[ec2-user@ip-xx-xx-xx-xx ~]$ wget mywwwdomain.com
--2020-12-21 15:57:26-- http://mywwwdomain.com/
Resolving mywwwdomain.com (mywwwdomain.com)... 55.55.55.55
Connecting to mywwwdomain.com (mywwwdomain.com)|55.55.55.55|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://mywwwdomain.com/ [following]
--2020-12-21 15:57:26-- https://mywwwdomain.com/
Connecting to mywwwdomain.com (mywwwdomain.com)|55.55.55.55|:443... connected.
ERROR: The certificate of ‘mywwwdomain.com’ is not trusted.
ERROR: The certificate of ‘mywwwdomain.com’ hasn't got a known issuer.
The certificate's owner does not match hostname ‘mywwwdomain.com’
[ec2-user@ip-xx-xx-xx-xx ~]$
55.55.55.55-我的IP地址
如何进一步调试并修复此问题?
如果在新文件中添加了新域,请确保新文件正确包含在主httpd配置文件中。您可以通过发出以下命令获得apache正在服务的VHs的列表:# apache2ctl -S
(在Debian/Uubuntu上(、# apachectl -S
(在CentOS/RHEL上(或# httpd -S
。