【发布时间】:2019-02-05 20:04:32
【问题描述】:
使用 Ubuntu 18.04.01,我在 apache 中设置了多个站点,因此我可以在本地处理它们。这是我目前的设置:
/etc/hosts
127.0.0.1 localhost
127.0.1.1 site1.local
127.0.1.1 site2.local
/var/www
site1.com
site2.com
/etc/apache2/sites-available
000-default.conf
default-ssl.conf
site1.com.conf
site2.com.conf
site1.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/site1.com
ServerName site1.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
site2.com.conf 看起来与此相同,但将“site1”与“site2”交换
我也跑了:
sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf
现在 /sites-enabled 中的符号链接已经存在。
但是我得到的行为是当我进入浏览器并输入http://site1.local 时,它加载得很好。但是当我输入http://site2.local 时,浏览器只会重定向回site1。
请指教。
【问题讨论】:
标签: apache ubuntu localhost ubuntu-18.04