在Apache中的多个域

在设置多个域时遇到困难

当我sudo a2ensite的例子2,它不会加载,无论exampe1是否启用或禁用…当然取下了自己的example1。 这里是两个文件(example2是基于example1)

在网站 – 可用我有example1文件

<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName example1.com ServerAlias example1.com DocumentRoot /var/www/example1 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/example1/> Options Indexes FollowSymLinks MultiViews AllowOverride All 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 /home/ubuntu/www/logs/example1/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /home/ubuntu/www/logs/example1/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> 

和example2文件

 <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName example2.com ServerAlias example2.com DocumentRoot /var/www/example2 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/example2/> Options Indexes FollowSymLinks MultiViews AllowOverride All 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 /home/ubuntu/www/logs/example2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /home/ubuntu/www/logs/example2/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> 

我有

 NameVirtualHost *:80 

在ports.conf中

我错过了什么?

你真的把你的configuration复杂化了。 首先。 看看http://httpd.apache.org/docs/2.0/vhosts/examples.html

然后,将这些文件修剪到最低限度。 确保激活站点并确保目录存在。 这应该够了吧。 另外,不要忘了重新加载Apache之后。