在一台服务器上的多个Zend框架的网站 [英] Multiple Zend framework sites on one server

查看:284
本文介绍了在一台服务器上的多个Zend框架的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法设置我的httpd.conf或.htaccess文件来识别多个Zend Framework的站点一台服务器上。

有关的发展,我有一台服务器,我想设置的站点,以便我可以访问他们像本地主机/ APP1,本地主机/ APP2等。

所以现在,当我去到localhost / APP1它确实成功地重定向到l​​ocalhost / APP1 /公/ index.php文件,但是当我去到localhost / APP1 /指数/指数我得到一个404

下面是我的虚拟主机文件:

 <虚拟主机*:80>
    的ServerAdmin网站管理员@本地
    的DocumentRoot/无功/网络
    <目录/>
        有FollowSymLinks
        设置AllowOverride无
    < /目录>
    <目录/无功/网络/ APP1 /公众>
        选择了FollowSymLinks指标多视图
        设置AllowOverride所有
        订购允许,拒绝
        允许所有
    < /目录>
    错误日志日志/ error.log中
    的CustomLog日志/ access.log的共同
< /虚拟主机>
 

和这里是在/ var / WWW / APP1目录我的.htaccess文件:

  RewriteEngine叙述上

的RewriteCond%{} REQUEST_FILENAME -s [OR]
的RewriteCond%{} REQUEST_FILENAME -l [OR]
的RewriteCond%{} REQUEST_FILENAME -d

重写规则^ * $ /app1/public/index.php [NC,R,L]
 

如果我更改虚拟主机DocumentRoot的行文件到的DocumentRoot/无功/网络/ APP1 /公众然后APP1工作正常,但我只能访问之一... ...在的http://本地主机。这可能吗?如果在/ var / www是文档根目录,然后如果我去到localhost / APP1我希望发生的是,这些要求需要重定向到l​​ocalhost / APP1 /公/ index.php的,如果我去到localhost / APP2这些请求需要重定向到l​​ocalhost / APP2 /公/ index.php文件。

我希望我解释这个显然,任何帮助是AP preciated。

最后
我喜欢菲尔的最佳解决方案,因为我不希望有改变我的本地hosts文件,并使用ServerName指令。如果你拥有的每个应用程序的独立域名这将是罚款在生产环境中,而不是发展。

除此之外,我用一个备用目录提供网页内容时,有一个403禁止的问题。正如我所说,烫发似乎正确的问题是与SE_Linux和文件的安全上下文没有被设置为httpd_sys_content_t。我张贴这种解决方案,我发现<一href="http://stackoverflow.com/questions/6807317/fixing-403-forbidden-on-alias-directory-with-apache">here,因为它专门处理这一问题。谢谢你。

解决方案

下面是我会怎么做?

  1. 安装应用程序的某个地方任意的,而是文档根目录以外的,例如 /主页/ sudol /应用程序/ APP1 /家庭/ sudol /应用程序/ APP2 。请确保您的Apache用户可以遍历这个路径和读取文件。<​​/ p>

  2. 别名在公开目录中的&LT;虚拟主机&GT; 部分。

     别名/ APP1 /家庭/ sudol /应用程序/ APP1 /公
    别名/ APP2 /家庭/ sudol /应用程序/ APP2 /公
     

  3. 设置您的访问,并在适当的&LT重写规则;目录&GT; 部分(每个应用程序),例如:

     &LT;目录/家/ sudol /应用程序/ APP1 /公众&GT;
        选择了FollowSymLinks指标多视图
        设置AllowOverride所有
        订购允许,拒绝
        允许所有
    
        RewriteEngine叙述上
        的RewriteBase / APP1
        的RewriteCond%{} REQUEST_FILENAME -s [OR]
        的RewriteCond%{} REQUEST_FILENAME -l [OR]
        的RewriteCond%{} REQUEST_FILENAME -d
        。重写规则^ * $  -  [NC,L]
        重写规则^ * $的index.php [NC,L]
    &LT; /目录&GT;
     

  4. 删除的.htaccess 文件,您将不再需要它们

附录

请确保你设置你的应用程序配置唯一的会话名称。您还可以设置特定的Cookie路径,但这是可选的,如:

 ; APP1 /应用/的configs /的application.ini
resources.session.name =APP1
resources.session.cookie_path =/ APP1 /

; APP2 /应用/的configs /的application.ini
resources.session.name =APP2
resources.session.cookie_path =/ APP2 /
 

I'm having trouble setting up my httpd.conf or .htaccess files to recognize multiple zend framework sites on one server.

For development, I have just one server and I'm trying to setup the sites so I can access them like localhost/app1, localhost/app2, etc.

So right now, when I go to localhost/app1 it does successfully redirect to localhost/app1/public/index.php, however when I go to localhost/app1/index/index I get a 404.

Here is my vhosts file:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www"
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory "/var/www/app1/public">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog logs/error.log
    CustomLog logs/access.log common
</VirtualHost>

and here is my .htaccess file from the /var/www/app1 directory:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ /app1/public/index.php [NC,R,L]

If I change the DocumentRoot line in the vhosts file to DocumentRoot "/var/www/app1/public" then app1 does work correctly, but I can only access that one... at http://localhost. Is this possible? What I want to happen is if /var/www is the document root, then if I go to localhost/app1, those requests need to redirect to localhost/app1/public/index.php and if I go to localhost/app2 those requests need to redirect to localhost/app2/public/index.php.

I hope I explained this clearly, any help is appreciated.

In the end
I liked Phil's solution best because I didn't want to have to change my local hosts file and use the ServerName directive. It would be fine in a production environment if you own a separate domain name for each app, but not for development.

In addition to that, I was having a 403 forbidden problem when using an alternate directory for serving up web content. As I stated, the perms seemed correct the problem was with SE_Linux, and the security context of the files not being set to httpd_sys_content_t. I'm posting that solution that i found here, as it deals specifically with the issue. Thanks.

解决方案

Here's what I'd do...

  1. Install your applications somewhere arbitrary but outside the document root, eg /home/sudol/apps/app1 and /home/sudol/apps/app2. Make sure your Apache user can traverse this path and read the files.

  2. Alias the public directories in your <VirtualHost> section

    Alias /app1 /home/sudol/apps/app1/public
    Alias /app2 /home/sudol/apps/app2/public
    

  3. Setup your access and rewrite rules in the appropriate <Directory> sections (one for each app), eg

    <Directory "/home/sudol/apps/app1/public">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    
        RewriteEngine On
        RewriteBase /app1
        RewriteCond %{REQUEST_FILENAME} -s [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </Directory>
    

  4. Delete the .htaccess files as you will no longer need them

Addendum

Make sure you set unique session names in your application config. You can also set specific cookie paths but this is optional, eg

; app1/application/configs/application.ini
resources.session.name = "app1"
resources.session.cookie_path = "/app1/"

; app2/application/configs/application.ini
resources.session.name = "app2"
resources.session.cookie_path = "/app2/"

这篇关于在一台服务器上的多个Zend框架的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆