我在一台服务器上有两台虚拟主机:srv-08.zone08.edu:80 tulip.zone08.edu:8088
当我把srv-08.zone08.edu:8088,我什么也得不到。
文件/etc/apache2/ports.conf:
NameVirtualHost srv-08.zone08.edu:80 NameVirtualHost tulip.zone08.edu:8088 Listen 80 Listen 8088
文件configurationsrv-08.zone08.edu(less数第一行):
<VirtualHost srv-08.zone08.edu:80> ServerAdmin [email protected] ServerName srv-08.zone08.edu ***
文件configurationtulip.zone08.edu(less数第一行):
<VirtualHost tulip.zone08.edu:8088> ServerAdmin [email protected] ServerName tulip.zone08.edu ***
我认为,只要改变VirtualHost和NameVirtualHost就足够了。 但这还不够…(这样,我的主机就不能从其他连接的PC上看到了,有什么想法吗?
Cofig文件:
<VirtualHost tulip.zone08.edu:8088> ServerAdmin [email protected] ServerName tulip.zone08.edu DocumentRoot /usr/apache ErrorLog /home/usr/apache2.log RewriteEngine on RewriteCond %{HTTP_HOST} srv-08.zone08.edu RewriteRule (.*) http://srv-08.zone08.edu/$1 <Directory "/usr/apache"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from all </Directory> </VirtualHost>
configuration是正确的。 一切正常,除了RewriteEngine和正确的主机名
既然你有他们在同一台服务器上,并且服务器正在监听两个端口,当你连接到一个Apache实际处理的端口时,你不能得到任何东西。 虽然有一些你可以做的事情,可能会也可能不是你想要的。 我会试着看看我能否帮助你。
首先,最好把你的configuration文件中的系统IP地址,而不是主机名。 这样,即使你有DNS麻烦,也不会混淆Apache。
这是一个郁金香服务器的新configuration,只记得把你自己的实际IP地址,而不是我使用的1.2.3.4。 你还需要修复一个path到我写了PATH-TO-LOGFILE的可用日志
<VirtualHost 1.2.3.4:8088> ServerAdmin [email protected] ServerName tulip.zone08.edu DocumentRoot /usr/apache ErrorLog /home/usr/apache2.log RewriteEngine on RewriteLog PATH-TO-LOGFILE RewriteLogLevel 3 RewriteCond %{HTTP_HOST} srv-08.zone08.edu RewriteRule (.*) http://srv-08.zone08.edu/$1 [R,L] <Directory "/usr/apache"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from all </Directory> </VirtualHost>
我修复了另一个拼写错误,你有/ VintualHost而不是/ VirtualHost,并且为重写过程添加了一些日志logging。 一旦你按照你想要的方式运行,你可以删除RewriteLog和RewriteLogLevel行,但是现在你需要它们来弄清楚我可能误解的任何东西。