如何为zendframework配置vhost?

时间:2011-02-28 20:12:11

标签: php zend-framework

我想将vhost配置为zf,但我不知道该怎么做,如果你能提供帮助就会很棒。感谢

4 个答案:

答案 0 :(得分:7)

创建虚拟主机的过程取决于版本的APACHE ,但整体保持不变。

APACHE (向下滚动 APACHE2

如果您使用常规apache,例如MAMP堆栈或Centos上的apache,请执行以下操作。

编辑httpd.conf文件,在apache conf目录中,将其添加到文件末尾 (如果使用mamp,则在application / mamp / conf / apache中,否则它应该在/ etc / apache / conf中)

NameVirtualHost *:80
<VirtualHost *:80>
     ServerName quickstart.local
     DocumentRoot /Applications/MAMP/htdocs/quickstart/public
     SetEnv APPLICATION_ENV "development"
     <Directory /Applications/MAMP/htdocs/quickstart/public>
          DirectoryIndex index.php
          AllowOverride All
          Order allow,deny
          Allow from all
     </Directory>
</VirtualHost>

在此之后,重新启动apache,

sudo /etc/init.d/apache restart

或通过你的xamp堆栈客户端重启(如果存在)。

在这种情况下,您现在需要让浏览器知道域名“quickstart.local”。

进入您的主机文件。

sudo vim /etc/hosts

添加以下行。

127.0.0.1       quickstart.local

出口

全部完成。


如果你使用APACHE2,你做同样的事情,而不是编辑httpd.conf文件。 进入你的/etc/apache2.conf

确保

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

没有注释。

现在进入可用的网站。

为域名创建一个新文件名,在本例中为“quickstart.local”

<VirtualHost *:80>
ServerName quickstart.local
ServerAlias quickstart.local
DocumentRoot /var/www/quickstart/public #or whatever the path is.
SetEnv APPLICATION_ENV "development"
 <Directory /var/www/quickstart/public>
      DirectoryIndex index.php
      AllowOverride All
      Order allow,deny
      Allow from all
 </Directory>
</VirtualHost>

保存

现在进入启用网站的文件夹。

执行以下操作

sudo ln -s /etc/apache2/sites-available/quickhost.local .

现在像上面讨论的那样编辑Hosts文件(如果是一个组成的域名)。 你应该好。

如果这不起作用,可能是您没有为.htaccess启用目录。

要使Zend正常工作,您需要确保将目录设置为

“AllowOveride ALL”

<Directory <Path to whatever>>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

这允许Zend路由系统工作。默认情况下,有时会将其设置为关闭。

答案 1 :(得分:2)

我通常在/etc/apache/sites-enabled/000-default的apache配置中有这些 在这种情况下,我使用的是ubuntu + apache 2:

NameVirtualHost zf.local:80
<VirtualHost zf.local:80>
DocumentRoot "/home/devlor/Sites/zf/public"
ServerName symfony.local
  SetEnv APPLICATION_ENV development
    <Directory "/home/devlor/Sites/zf/public">
      Options Indexes MultiViews FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

答案 2 :(得分:1)

@ tawfekov:

如果/home/devlor不在Apache的可信目录列表中,则无效:

<Directory /home>
  Order allow,deny
  Deny from none
  Allow from all
</Directory>

答案 3 :(得分:0)

<VirtualHost *:80>
    ServerName overstock.local
    DocumentRoot "C:\xampp\htdocs\overstock"
 <Directory "C:\xampp\htdocs\overstock">
    AllowOverride All
   </Directory>

 </VirtualHost>

然后将htaccess更改为

   Options +FollowSymLinks -MultiViews
   RewriteEngine On
   RewriteBase /overstock/

   RewriteCond %{REQUEST_URI} !/public [NC]
   RewriteRule ^(.*)$ public/$1 [L]