【发布时间】:2014-07-05 22:56:59
【问题描述】:
我尝试在默认的localhost 之外设置一个虚拟主机。
每当我尝试调用我的虚拟主机http://test 时,我都会得到位于http://localhost 目录中的默认Apache2 索引文件。此外,在禁用 (a2dissite) 两个 VirtualHost 文件和重新加载 apache (service apache2 reload) 后,apache 仍会返回此页面。
虚拟主机不工作会出什么问题?
配置:
我的目录结构如下:
/var/www/html # Default localhost dir
/var/www/html7index.html # Apache2 default index
/var/www/test # HTML dir for the virtual host
/var/www/test/index.html # My "website"
/etc/hosts的内容:
127.0.0.1 localhost
127.0.1.1 Laptop
127.0.0.1 test
/etc/apache2/sites-available的目录内容:
000-default.conf
default-ssl.conf
test.conf
文件000-default.conf:
<VirtualHost localhost:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
文件test.conf:
<VirtualHost test:80>
ServerAdmin test@localhost
ServerName test
NameVirtualHost test
ServerAlias test
DocumentRoot /var/www/test
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
【问题讨论】:
-
所以你已经做了
a2ensite test? -
是的,当然。抱歉,忘记了。
-
您的 vHost 文件和主机文件对我来说看起来不错。您在进行 a2ensite test 时是否获得了 apache 默认页面?你能从日志中找到任何东西吗?
-
日志中没有任何内容。但我想通了。看我自己的答案。谢谢。
标签: apache ubuntu virtualhost