我刚刚安装了ubuntu(11.04)。
我已经安装了apache / mysql / php等。
我有几个网站
/var/www/site1
/var/www/site2
/var/www/site3
我希望能够在以下位置访问这些
http://site1.local
http://site2.local
http://site3.local
所以在我的主机文件中
127.0.0.1 site1.local
127.0.0.1 site2.local
127.0.0.1 site3.local
然后我已经复制了/etc/apache2/sites-available/default
3次。
所以现在我有:
/etc/apache2/sites-available/site1
/etc/apache2/sites-available/site2
/etc/apache2/sites-available/site3
这些都看起来像(带有适当的sitex名称)
<VirtualHost site1.local>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/site1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/site1/>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
然后在终端我打电话
sudo a2ensite site1 site2 site3 && sudo /etc/init.d/apache2 reload
除了只有一个虚拟主机可以同时工作(包括默认),这似乎可以工作,我在做什么错呢?
- 重新加载Web服务器配置apache2
apache2:无法可靠地确定服务器的完全限定域名,
对ServerName使用127.0.1.1
[2011年4月15日星期五10:45:27] [警告] NameVirtualHost *:80没有VirtualHosts
文件:/ etc / hosts
127.0.0.1 site1.local
127.0.0.1 site2.local
127.0.0.1 site3.local
文件:/etc/apache2/apache2.conf
[...]
NameVirtualHost *:80
[...]
文件:/ etc / apache2 / sites-available / site {i} .local.conf(而不是{i}插入数字:1或2或3)
<VirtualHost *:80>
ServerName site{i}.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/site{i}
[...]
</VirtualHost>
在目录/ etc / apache2 / sites-enabled /中创建符号链接:
@site{i}.local.conf
重新启动apache,玩得开心:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句