如何使用apache2和zend创建多个虚拟主机

发布于 2025-01-06 21:44:04 字数 1599 浏览 1 评论 0原文

我已经在 /var/www/zendapp 创建了 zend 应用程序,但我还安装了 mediawiki 应用程序 在 /var/www/mediawiki

现在我想使用 http://mediawiki.local

http://zendapp.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

它会将我重定向到 http://zendapp.local/mediawiki/index.php/Main_Page

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沦落红尘 2025-01-13 21:44:04

执行以下操作: 单独的虚拟主机块:

 Listen 80
 NameVirtualHost *:80

 <VirtualHost *:80>

  ServerName mediawiki.local
  DocumentRoot /var/www/mediawiki

  #all other settings
  .
  .
  .
 </VirtualHost>

 <VirtualHost *:80>

  ServerName zendapp.local 
  DocumentRoot /var/www/zendapp/public

  #all other settings
  .
  .
  .

 </VirtualHost>

Do this: Separate virtualhost blocks:

 Listen 80
 NameVirtualHost *:80

 <VirtualHost *:80>

  ServerName mediawiki.local
  DocumentRoot /var/www/mediawiki

  #all other settings
  .
  .
  .
 </VirtualHost>

 <VirtualHost *:80>

  ServerName zendapp.local 
  DocumentRoot /var/www/zendapp/public

  #all other settings
  .
  .
  .

 </VirtualHost>
好久不见√ 2025-01-13 21:44:04

看看这个博客,他的回答有效!

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

少跟Wǒ拽 2025-01-13 21:44:04
  1. 您不会不小心忘记包含此网站吗?也就是说,在“sites-enabled”目录中应该被适当的引用。通常您应该运行以下命令:

    sudo a2ensite 主机名

    sudo service apache2 reload

  2. 作为第二种变体,我可以假设“DocumentRoot”应该以斜杠结尾:

    DocumentRoot /var/www/zendapp/public/

  1. 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

  2. As a second variant, I can suppose, that 'DocumentRoot' should be ended by a slash:

    DocumentRoot /var/www/zendapp/public/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文