我正在尝试将Apache配置为网内Web服务器,并且使用的是sites-available / sites-enabled功能,而不仅仅是静态vhost文件.我设置了几个VirtualHosts,都有一个独特的DocumentRoot,但是对所有VirtualHosts的请求只是提供了“It’s Working!”.默认文件.我不能为我的生活弄清楚为什么它不会提供正确目录中的内容.这是virtualhost指令文件的内容,请告诉我是否需要发布更多内容.
默认(请注意,apache在启用站点时将其重命名为000-default,因此它不是排序问题)
NameVirtualHost *:80 ServerName emp <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName emp DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug,info,notice,warn,error,crit,# alert,emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
billmed
<VirtualHost *:80> ServerName billmed.emp ServerRoot /home/empression/Projects/billmed/web/httpdocs <Directory "/home/empression/Projects/billmed/web/httpdocs"> Order Allow,Deny Allow from All </Directory> </VirtualHost>
请注意,我有emp和billmed.emp的DNS区域,以及/ etc / hosts中的条目.我的最终目标是将此计算机设置为具有自定义tld(emp)的内部网络服务器,但进度相当缓慢.
更多信息
/ etc / hosts条目
#custom-sites 192.168.1.100 emp 192.168.1.100 billmed.emp
ports.conf
# If you just change the port or add more ports here,you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default # This is also true if you have upgraded from before 2.2.9-3 (i.e. from # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and # README.Debian.gz #NameVirtualHost *:80 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here,you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
ls -l sites-enabled
empression@empression-server1:/etc/apache2/sites-available$ls -l ../sites-enabled/ total 0 lrwxrwxrwx 1 root root 26 2010-05-22 12:36 000-default -> ../sites-available/default lrwxrwxrwx 1 root root 26 2010-05-22 13:33 billmed -> ../sites-available/billmed
更新2010-06-16
几个星期以来我一直无法解决这个问题,但是我已经尝试了下面发布的所有解决方案,但是仍然无法解决问题所以我已经添加了一笔赏金.
更新
这是apache2ctl -t -D DUMP_VHOSTS的输出
empression@empression-server1:~$apache2ctl -t -D DUMP_VHOSTS apache2: Could not reliably determine the server's fully qualified domain name,using 127.0.1.1 for ServerName [Mon Jul 12 14:29:01 2010] [warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts VirtualHost configuration: 192.168.1.100:80 is a NameVirtualHost default server billmed.emp (/etc/apache2/sites-enabled/billmed:1) port 80 namevhost billmed.emp (/etc/apache2/sites-enabled/billmed:1) Syntax OK
解决方法
在虚拟主机定义文件中,更正以下行.
ServerRoot / home / empression / Projects / billmed / web / httpdocs
至
DocumentRoot / home / empression / Projects / billmed / web / httpdocs
使用DocumentRoot指令来提供虚拟主机.
这里是更多信息的链接
http://httpd.apache.org/docs/2.2/mod/core.html
更新您的虚拟主机定义(/ etc / apache2 / sites-enabled / billmed),如下所示,
<VirtualHost *:80> ServerName billmed.emp DocumentRoot /home/empression/Projects/billmed/web/httpdocs <Directory "/home/empression/Projects/billmed/web/httpdocs"> Order Allow,Deny Allow from All </Directory> </VirtualHost>