如何使用apache2和zend创建多个虚拟主机
我已经在 /var/www/zendapp 创建了 zend 应用程序,但我还安装了 mediawiki 应用程序 在 /var/www/mediawiki
现在我想使用 http://mediawiki.local
我怎样才能做到这一点?
我有过几次不成功的尝试。到目前为止,我编辑了 /etc/hosts 并添加了这两行:
127.0.0.1 zendapp.local
127.0.0.1 mediawiki.local
我还在 /etc/apache2/sites-available/ 中创建了两个文件:
zendapp
mediawiki
mediawiki:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mediawiki>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
zendapp:
ServerName zendapp.local
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/zendapp/public
<Directory /var/www/zendapp/public>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
但现在似乎只有 zendapp.local 有效,如果我转到: http://mediawiki.local
I have created zend application in /var/www/zendapp , but i have also installed mediawiki app
in /var/www/mediawiki
Now i want to access mediawiki app with http://mediawiki.local
and http://zendapp.local.
How can i do that?
I had couple of unsuccessful atempts. So far i edited /etc/hosts and added these two lines:
127.0.0.1 zendapp.local
127.0.0.1 mediawiki.local
I also created two files in /etc/apache2/sites-available/ :
zendapp
mediawiki
mediawiki :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mediawiki>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
zendapp :
ServerName zendapp.local
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/zendapp/public
<Directory /var/www/zendapp/public>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But now it semes that only zendapp.local works, and if I go to :
http://mediawiki.local
it redirects me to http://zendapp.local/mediawiki/index.php/Main_Page
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
执行以下操作: 单独的虚拟主机块:
Do this: Separate virtualhost blocks:
看看这个博客,他的回答有效!
http://justanswersnobullshit.wordpress.com/
在对在线视频教程感到沮丧后,我自己尝试了这个如何设置多个虚拟主机
Check out this blog, his answer worked!
http://justanswersnobullshit.wordpress.com/
I tried this out myself, after being frustrated by online video tutorials on how to setup multiple virtual hosts
您不会不小心忘记包含此网站吗?也就是说,在“sites-enabled”目录中应该被适当的引用。通常您应该运行以下命令:
sudo a2ensite 主机名
sudo service apache2 reload
作为第二种变体,我可以假设“DocumentRoot”应该以斜杠结尾:
DocumentRoot /var/www/zendapp/public/
And you do not accidentally forgot to include this site? That is, in the 'sites-enabled' directory should be by appropriate reference. Usually you should run the following commands:
sudo a2ensite host_name
sudo service apache2 reload
As a second variant, I can suppose, that 'DocumentRoot' should be ended by a slash:
DocumentRoot /var/www/zendapp/public/