我正在尝试使用 Apache/Ubuntu 上的虚拟主机在同一 IP 上设置两个网站。如果此信息相关,地点 1正在使用 https,而地点 2仅限 http。
我的问题是地点 2将加载文档根目录地点 1而不是自己的,同时继承了https即使我输入http。
我真的不知道自己在做什么,类似线程中建议的所有内容要么不起作用,要么我不明白——希望下面复制的配置文件中存在明显的错误:
网站1
<VirtualHost *:80>
ServerName site1.com
Redirect permanent / h t t ps://site1.com ## ignore spacing ##
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /var/www/site1/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/site1/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/site1/private.key
SSLCACertificateFile /etc/apache2/ssl/site1/ca_bundle.crt
</VirtualHost>
地点 2
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot /var/www/site2/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
运行 apache2ctl -S 返回以下内容
VirtualHost configuration:
*:443 site1.com (/etc/apache2/sites-enabled/site1.conf:5)
*:80 is a NameVirtualHost
default server site1.com (/etc/apache2/sites-enabled/site1.conf:1)
port 80 namevhost site1.com (/etc/apache2/sites-enabled/site1.conf:1)
port 80 namevhost site2.com (/etc/apache2/sites-enabled/site2.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
提前致谢