我从centos 6.5的源代码中构建了php 5.4 -尽管一切看起来都很好,但它在apache中无法工作


I built php 5.4 from sources on centos 6.5 - it doesn't work in apache despite everything seeming ok

构建和安装完成,没有任何错误。没有其他php安装在这个系统上。

模块似乎正在加载apache:

# grep -i php /etc/httpd/conf/httpd.conf
LoadModule php5_module        /usr/lib64/httpd/modules/libphp5.so

# apachectl -M  | grep php
 php5_module (shared)

我对/usr/lib64/httpd/modules/libphp5做了一个修改so和我构建的是同一个文件

Php从命令行执行起来似乎没问题。

# /usr/local/php54/bin/php -f /var/www/html/phpinfo.php  | more
phpinfo()
PHP Version => 5.4.29
System => Linux xxxx.xxx.com 2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014 x86_64
Build Date => Aug  7 2014 14:30:39
Configure Command =>  './configure'  '--prefix=/usr/local/php54' '--with-config-file-path=/usr/local/php54/etc' '--with-config-file-scan-
dir=/usr/local/php54/etc/php.d' '--with-libdir=lib64' '--with-mysql' '--with-mysqli' '--with-pdo-mysql' '--enable-mbstring' '--disable-de
bug' '--disable-rpath' '--with-bz2' '--with-curl' '--with-gettext' '--with-iconv' '--with-openssl' '--with-gd' '--with-mcrypt' '--with-pc
re-regex' '--with-zlib' '--with-apxs2'
Server API => Command Line Interface
...blah blah

apache的错误日志中没有显示任何东西:

# more /var/log/httpd/error_log
[Fri Aug 08 12:40:57 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Aug 08 12:40:57 2014] [notice] Digest: generating secret for digest authentication ...
[Fri Aug 08 12:40:57 2014] [notice] Digest: done
[Fri Aug 08 12:40:57 2014] [warn] ./mod_dnssd.c: No services found to register
[Fri Aug 08 12:40:57 2014] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.4.29 configured -- resuming normal operations
我的测试脚本是这样的:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

当我用firefox从同一主机上访问该页面时,我从浏览器得到的全部结果是:

<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

我在这里错过了什么?

selinux被完全禁用

# getsebool -a | egrep 'cgi|builtin_scriptin'
getsebool:  SELinux is disabled
php . ini:

# grep -v ';' /usr/local/php54/etc/php.ini | sed '/^'s*$/d'
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]

问题不在于您的php.ini,很可能是与您的Apache配置有关。

你有LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so在你的Apache httpd.conf,所以Apache知道使用PHP,但你需要确保你有一个像AddType application/x-httpd-php .php这样的行,让Apache知道何时使用

相关文章: