我使用亚马逊Linux与Apache(Apache/2.4.25(亚马逊))。我有几个域名和几个子域名。我使用letsencrypt/cerbot作为ssl证书。这工作。我可以访问https而没有问题。但是,我无法访问我的任何非默认http虚拟主机。它们都重新路由到默认虚拟主机。我只发现了其他一些没有解析的帖子,这似乎很难搜索。 Letsencrypt抱怨说我需要虚拟主机的单独文件,这就是我为http和https所做的。我已经把所有的http转移到了httpd.conf中,但这也不起作用。我的域名和子域名也有“A”记录。我错过了什么?Apache虚拟主机https工作,但http只需默认虚拟主机
###Begin httpd.conf###
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User nona_yo_biz
Group nona_yo_biz
ServerAdmin [email protected]
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Load config files in the "/etc/httpd/conf.d" directory, if any.
# This is where my ssl files are stored
IncludeOptional conf.d/*.conf
#Some other module crap etc
#Some other AWS settings
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/basesite"
ServerName basesite.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/sub1example"
ServerName sub1.example.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/sub2example"
ServerName sub2.example.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/example"
ServerName example.com
</VirtualHost>
###End httpd.conf###
###BEGIN ssl.conf###
Listen 443 https
#Some other stuff
<VirtualHost *:443>
DocumentRoot "/var/www/html/basesite"
ServerName basesite.com:443
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv3
SSLProxyProtocol all -SSLv3
SSLHonorCipherOrder on
#Some other stuff
CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
ServerAdmin s[email protected]
SSLCertificateFile /etc/letsencrypt/live/basesite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/basesite.com/privkey.pem
</VirtualHost>
###END ssl.conf
###Separate conf file for vhost###
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/sub1example"
ServerName sub1.example.com:443
SSLCertificateFile /etc/letsencrypt/live/basesite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/basesite.com/privkey.pem
</VirtualHost>
###Separate conf file for vhost###
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/sub2example"
ServerName sub2.example.com:443
SSLCertificateFile /etc/letsencrypt/live/basesite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/basesite.com/privkey.pem
</VirtualHost>
###Separate conf file for vhost###
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/example"
ServerName example.com:443
SSLCertificateFile /etc/letsencrypt/live/basesite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/basesite.com/privkey.pem
</VirtualHost>
编辑的apachectl -S输出
sudo apachectl -S
VirtualHost configuration:
*:443 is a NameVirtualHost
default server basesite.com (/etc/httpd/conf.d/ssl.conf:57)
port 443 namevhost basesite.com (/etc/httpd/conf.d/ssl.conf:57)
port 443 namevhost sub1.example.com (/etc/httpd/conf.d/ssl_sub1_exa.conf:1)
port 443 namevhost example.com (/etc/httpd/conf.d/ssl_exa.conf:1)
port 443 namevhost sub2.example.com (/etc/httpd/conf.d/ssl_sub2_exa.conf:1)
*:80 is a NameVirtualHost
default server basesite.com (/etc/httpd/conf/httpd.conf:392)
port 80 namevhost basesite.com (/etc/httpd/conf/httpd.conf:392)
port 80 namevhost sub1.example.com (/etc/httpd/conf/httpd.conf:400)
alias sub1.example.com:80
port 80 namevhost example.com (/etc/httpd/conf/httpd.conf:407)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html/"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex default: dir="/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="nona_yo_biz" id=404
Group: name="nona_yo_biz" id=505
我已经试过了。在apache 2.4中,它已从文档中删除,并在检查语法时抛出警告/错误。所以我没有实际部署它就删除了它。 – vdidxho