我正在尝试将Apacheconfiguration为networking内networking服务器,并且正在使用网站可用/网站启用的function,而不仅仅是静态的虚拟主机文件。 我build立了几个VirtualHosts,都有一个独特的DocumentRoot,但是所有VirtualHosts的请求只是提供了“It's Working!”。 默认文件。 我不能为了我的生活找出为什么它不会提供正确目录中的内容。 这里是virtualhost指令文件的内容,让我知道如果我需要发布更多。
default (注意apache在启用网站时将其重命名为000-default ,所以这不是一个sorting问题)
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>
请注意,我有DNS区域为emp和billmed.emp ,以及/ etc / hosts中的条目。 我的最终目标是将这台机器设置为一个自定义tld(emp)的内部networking服务器,但进度一直非常缓慢。
/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 (ie 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
我几个星期都没有做这个工作,但是现在我已经尝试了下面所有的解决scheme,但是仍然无法解决问题,所以我添加了一个赏金。
这是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 <目录“/ home / empression / Projects / billmed / web / httpdocs”> 订单允许,拒绝 全部允许 </目录> </虚拟主机>
@ yasin是正确的; 你需要让你的VirtualHosts指定一个DocumentRoot ('… httpd服务文件的目录…')而不是ServerRoot ('…服务器所在的目录。通常它将包含子目录conf /和日志/ ….')
还可能有另外一个问题,但是这个部分肯定是错误的。
你在/etc/hosts或DNSconfiguration中的映射是什么? 尝试用127.0.0.1代替*我的意思是<VirtaulHost 127.0.0.1:80>和NameVirtualHost 127.0.0.1:80 。 什么在你的/etc/apache2/ports.conf ? 检查是否所有符号链接都已到位。 例如: /etc/apache2/sites-enabled/<yoursite.emp>
编辑:
试试这个:在ports.conf :
NameVirtualHost 127.0.0.1:80 Listen 127.0.0.1:80 NameVirtualHost 192.168.1.100:80 Listen 192.168.1.100:80
然后在000-default : <VirtualHost 127.0.0.1:80>在billmed : <VirtualHost 192.168.1.100:80
我会添加面具,而不是具体的IP到主机文件:
#/etc/hosts/ # custom-sites 127.0.0.1 emp 127.0.0.1 billmed.emp
在billmed文件中将ServerRoot更改为DocumentRoot 。
在/ etc / apache2 / sites-available /中添加/移动你的billmed vhostconfiguration。
然后启用这样的billmed vhost:
sudo a2ensite billmed
重新启动apache:
sudo service apache2 restart
编辑:改变a2enmod到a2ensite,愚蠢的错字:)
由于看起来您已经尝试了其他所有内容,请确保您包含主Apacheconfiguration文件中的启用站点的文件夹。
另外,如果你禁用所有的东西而不是billmed虚拟主机,你能把它从服务器文件从那个目录?
有没有指向全局configuration中的/ var / www的Alias指令,而不是在虚拟主机节内?
NameVirtualHost被注释掉。
如果你正在为每个设置容器,并使用ServerName / ServerAlias,你需要取消注释,重新启动Apache。
创build新的站点文件后,您是否已经使用apache,以便正在运行的守护程序重新读取其configuration?