【问题标题】:I built php 5.4 from sources on centos 6.5 - it doesn't work in apache despite everything seeming ok我从 centos 6.5 上的源代码构建了 php 5.4 - 尽管一切看起来都很好,但它在 apache 中不起作用
【发布时间】:2014-08-08 20:04:14
【问题描述】:

构建和安装完成,没有任何错误。此系统上没有安装其他 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 linux apache


    【解决方案1】:

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

    您的 Apache httpd.conf 中有 LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so,因此 Apache 知道使用 PHP,但您需要确保您有类似 AddType application/x-httpd-php .php 这样的行,以便 Apache 知道何时使用它。

    【讨论】:

    • 是的,就是这样!我添加了 SetHandler application/x-httpd-php 并且它起作用了。德普。谢谢。 6 分钟超时后,我会立即将您的答案标记为已接受。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    相关资源
    最近更新 更多