【问题标题】:How to configure different Virtual Hosts based on apache + php_cgi and apache+mod_php?如何根据apache+php_cgi和apache+mod_php配置不同的虚拟主机?
【发布时间】:2015-03-17 19:16:14
【问题描述】:

大家。

我有一个带有 Apache + mod_php 站点 (site1.local) 的 Cent OS 6.6 服务器。我需要用 php_cgi 配置第二个站点(site2.local)。因此,我创建了一个用户,授予他对 www 文件夹的权限,将 site1 配置为 mod_php,创建了一个 phpinfo.php。另外,我安装了php-cgi,并尝试配置虚拟主机,只适用于第一个站点,在第二个站点上是错误的:

the requested url /cgi-bin/phpinfo.php was not found onthis server.

这是我的配置: cat /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    ServerAdmin webmaster@site1.local
    DocumentRoot /var/www/wwwmaster/site1.local
    ServerName     site1.local
    ServerAlias www.site1.local
    ErrorLog logs/site1.local-error_log
    CustomLog logs/site1.local-access_log common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@site2.local
    DocumentRoot /var/www/wwwmaster/site2.local
    ServerName     site2.local
    ServerAlias www.site2.local

    ScriptAlias   /cgi_bin/    /usr/bin/php-cgi/
    Action        php-cgi        /cgi-bin
    AddHandler    php-cgi        php

    <Directory /usr/bin/php-cgi>
        Allow from all
    </Directory>

    <Directory "/var/www/wwwmaster/site2.local/">
        <FilesMatch "\.php">
            SetHandler    php-cgi
        </FilesMatch>
        Options Indexes FollowSymLinks    Includes ExecCGI
        AllowOverride All    
        Order Deny,Allow
        Allow from all
    </Directory>

    ErrorLog logs/site2.local-error_log
    CustomLog logs/site2.local-access_log common
</VirtualHost>

我做错了什么,我该如何解决?

【问题讨论】:

    标签: apache centos cgi virtualhost mod-php


    【解决方案1】:

    您只需取消注释 apache 配置文件中的 NameVirtualServer *:80 行。

    如果您想要多个端口的虚拟服务器,只需根据需要在 apache 配置文件中添加任意数量的NameVirtualServer *:[port number]

    【讨论】:

    • 你的意思是指令NameVirtualHost吗?它在配置中,但第二个站点仍然无法正常工作。
    猜你喜欢
    • 1970-01-01
    • 2011-05-04
    • 2017-06-14
    • 2012-08-22
    • 2011-10-13
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    相关资源
    最近更新 更多