Ubuntu 12.04
Apache2 已安装
# apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built: Mar 19 2014 21:11:49
已安装 PHP
# php --version
PHP 5.4.6-1ubuntu1.8 (cli) (built: Apr 4 2014 01:28:36)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
PHP 模块已安装并启用
# a2enmod php5
Module php5 already enabled
php5.conf 包含 SetHandler 指令
<IfModule mod_php5.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Order Deny,Allow
Deny from all
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
Order Deny,Allow
Deny from all
</FilesMatch>
# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>
但我的文件/var/www/wwwuser/data/domain.com/info.php
<?php phpinfo(); ?>
不执行 - 它是返回的源代码。为什么?
最佳答案
这个问题已经有一年了,对于 OP 来说可能为时已晚,但没有公认的答案,我从谷歌偶然发现。我正在处理一个非常相似的问题,也许我的解决方案将来会对某人有用:php.ini
中有一个 PHP 指令:
short_open_tag = Off
如果这是
Off
, 那么 PHP 将忽略 <? ?>
标签,因为它需要 <?php ?>
.所以就我而言,问题出在我的测试脚本上:
<? phpinfo(); ?>
解决方法是将标签改为
<?php
或者只是更新 INI 文件以读取 short_open_tag = On
.
关于php - Apache2返回php源码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24479265/