Apache虚拟主机无法解析PHP [英] Apache Virtual Host not parsing PHP

查看:595
本文介绍了Apache虚拟主机无法解析PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定启用我的Apache服务器上的虚拟主机,并选择使基于端口的。

I decided to enable virtual hosts on my Apache server, and chose to make it port-based.

第一件事,我做到了,当然,是RTFM。我跟着发现这里的说明。那么,它的工作 - 种。至于虚拟主机上运行,​​它的作用。从拉内容:80不同于:8080

First thing I did, of course, was RTFM. I followed the instructions found here. Well, it worked -- kind of. As far as the virtual host running, it does. The content pulled from :80 is different from :8080.

但PHP不工作。 原网站(80端口)正在运行PHP好了。端口8080的网站,但是,发送PHP到浏览器。我什么也看不到在浏览器中,但源$ C ​​$ C所示:

But PHP isn't working. The "original site", (port 80) is running PHP just great. The port 8080 site, however, sends the PHP to the browser. I see nothing in the browser, but the source code shows:

<?php
echo "It worked!";
?>

这话题似乎在几个网站上非常松散记录,但无论是我不能在其中找到一个解决方案,或列出的解决方案是不是为我工作。

This topic seems to be very loosely documented on a few websites, but either I can't find a solution in them, or the solution listed isn't working for me.

此外,虚拟主机本身运行良好。 PHP中,在另一方面,不

Again, the virtual host itself is running fine. PHP, on the other hand, is not.

这可能是什么任何想法?我应该提供从我的httpd.conf文件内容是什么,所以我不通过复制/炸掉我的问题粘贴整个事情?

Any ideas on what it could be? What content from my httpd.conf file should I provide so I don't blow up my question by copy/pasting the whole thing?

(对不起,我忘了张贴我的地方,菲尔有这些。增加以避免进一步的混乱)

(Sorry I forgot to post that I had these in place, Phil. Adding to avoid further confusion)

Listen 80
Listen 8080

NameVirtualHost *:80
NameVirtualHost *:8080

<VirtualHost *:80>
    ServerName mysite.com
    DocumentRoot /var/www/vhosts/Site1/httpdocs
</VirtualHost>

<VirtualHost *:8080>
    ServerName mysite.com
    DocumentRoot /var/www/vhosts/Site2/httpdocs
</VirtualHost>

我试过的标签中加入这样的:

I tried adding this inside the tags:

AddHandler php5-script .php
AddType text/html .php

...但无济于事。

...but to no avail.

推荐答案

这终于让我在正确的道路:

This finally put me on the right path:

<一个href=\"http://www.linuxquestions.org/questions/linux-server-73/php-not-working-on-one-vhost-but-works-on-all-others-851093/\">http://www.linuxquestions.org/questions/linux-server-73/php-not-working-on-one-vhost-but-works-on-all-others-851093/

下面是解决方案:

&LT;名录及GT; 部分,我包括这些行:

In the <Directory> section, I included these lines:

<IfModule sapi_apache2.c>
    php_admin_flag engine on
</IfModule>
<IfModule mod_php5.c>
    php_admin_flag engine on
</IfModule>

或者,我的服务器解决方案的节录复制/粘贴:

Or, a redacted copy/paste of the solution on my server:

<Directory "/var/www/vhosts/A2/httpdocs">
    <IfModule sapi_apache2.c>
        php_admin_flag engine on
    </IfModule>
    <IfModule mod_php5.c>
        php_admin_flag engine on
    </IfModule>

    (Other configuration parameters)

</Directory>

这篇关于Apache虚拟主机无法解析PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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