今天早上我们将 Debian Web 服务器升级到 Wheezy,一切正常后,Apache 似乎失去了执行 PHP 脚本的能力,而在升级之前它能够执行这些脚本。现在我们只能看到 PHP 代码,就好像没有启用 PHP 模块一样。
我检查了所有常见的问题,确保 PHP 模块已加载并安装,并确保 /etc/apache2/mods-enabled/php5.conf 已设置“SetHandler application/x-httpd-php”选项。我还遵循了在 Apache 上安装 PHP5 的最新文档,一切似乎都正常。Apache 错误日志中也没有任何表明存在问题的错误。
我是否遗漏了什么?
‘apachectl -t -D DUMP_MODULES |grep php’的输出:
Syntax OK
php5_module (shared)
‘www3:/etc/apache2# apache2 -v’ 的输出:
Server version: Apache/2.2.22 (Debian)
Server built: Jan 31 2014 18:55:37
/etc/apache2/mods-enabled/php5.conf 的内容:
<IfModule libphp5.so>
# <FilesMatch "\.ph(p3?|tml)$">
# </FilesMatch>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
# 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>
上次重启后的最新 apache 错误日志:
[Thu Apr 10 15:35:44 2014] [notice] caught SIGTERM, shutting down
[Thu Apr 10 15:35:45 2014] [warn] No JkLogFile defined in httpd.conf. Using default /var/log/apache2/mod_jk.log
[Thu Apr 10 15:35:45 2014] [warn] No JkShmFile defined in httpd.conf. Using default /var/log/apache2/jk-runtime-status
[Thu Apr 10 15:35:45 2014] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Apr 10 15:35:45 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Thu Apr 10 15:35:45 2014] [notice] Digest: generating secret for digest authentication ...
[Thu Apr 10 15:35:45 2014] [notice] Digest: done
[Thu Apr 10 15:35:45 2014] [warn] No JkLogFile defined in httpd.conf. Using default /var/log/apache2/mod_jk.log
[Thu Apr 10 15:35:45 2014] [warn] No JkShmFile defined in httpd.conf. Using default /var/log/apache2/jk-runtime-status
[Thu Apr 10 15:35:45 2014] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Apr 10 15:35:45 2014] [notice] Apache/2.2.22 (Debian) DAV/2 SVN/1.6.17 mod_fcgid/2.3.6 mod_jk/1.2.37 PHP/5.4.4-14+deb7u8 mod_ssl/2.2.22 OpenSSL/1.0.1e mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations
答案1
尝试运行以下命令:
sudo apt-get purge libapache2-mod-php5
sudo apt-get install libapache2-mod-php5
sudo a2enmod php5
sudo service apache2 restart
这将重新安装所有必要的软件包,以使 Apache 能够运行 mod_php。
您可能还需要确保文件 php5.conf 位于目录 /etc/apache2/mods-enabled 中。如果是,您应该会看到类似以下内容:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
答案2
事实证明这是 Apache 模块之一的问题。禁用其中大部分模块解决了问题,然后我们开始重新添加它们,直到其他所有模块都正常工作。
答案3
php5-suhosin
在 wheezy 中不再可用,但除非您清除该包,否则其.ini
文件仍然存在,/etc/php5/conf.d/
这将阻止 PHP 运行。
看:https://www.debian.org/releases/stable/i386/release-notes/ch-upgrading.html#idp836640