Apache安装在我的debian上,我想用不同的目录绑定两个域名。
cat /etc/hosts
127.0.0.1 hwy.local www.hwy.local
127.0.0.1 test.app www.test.app两个域名都绑定了127.0.0.1。
cat /etc/apache2/站点-可用/000-default.conf
ServerName www.hwy.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error_hwy.log
CustomLog ${APACHE_LOG_DIR}/access_hwy.log combined
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
ServerName www.test.app
ServerAdmin webmaster@localhost
DocumentRoot /home/debian9/app
ErrorLog ${APACHE_LOG_DIR}/error_app.log
CustomLog ${APACHE_LOG_DIR}/access_app.log combined
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all将相同的文件test.html保存在/var/www/html和/home/debian9/app中。
it is a test为什么www.hwy.local/test.html可以打开它,www.test.app遇到了错误。
This site can’t be reached 发布于 2018-09-07 08:49:21
问题不在于Apache,而在于您的/etc/hosts文件。
每个IP地址的主机文件中只能有一行。所以您的主机文件应该如下所示:
127.0.0.1 hwy.local www.hwy.local test.app www.test.app在同一行中使用127.0.0.1的所有条目。
https://serverfault.com/questions/929849
复制相似问题