简体   繁体   English

我在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

The build and the install finished without any errors. 构建和安装完成,没有任何错误。 No other php was installed on this system. 此系统上未安装其他php。

The module seems to be loading in apache: 该模块似乎正在apache中加载:

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

and

# apachectl -M  | grep php
 php5_module (shared)

I did a diff on /usr/lib64/httpd/modules/libphp5.so and what I built - they are the same file. 我对/usr/lib64/httpd/modules/libphp5.so及其构建的文件进行了比较-它们是同一文件。

Php seems to execute ok from the command line. PHP似乎可以从命令行执行ok。

# /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

Nothing shows up in apache's error log on start: 开始时,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

My test script is this: 我的测试脚本是这样的:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>

When I hit that page from the same host with firefox, all I get from the browser is: 当我使用firefox从同一主机访问该页面时,从浏览器获得的所有信息是:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>

What am I missing here? 我在这里想念什么?

selinux is completely disabled selinux被完全禁用

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

php.ini: 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]

The problem isn't with your php.ini most likely, chances are it is with your Apache config. 问题不在于您的php.ini很有可能与您的Apache配置有关。

You have LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so in your Apache httpd.conf , so Apache knows to use PHP, but you need to make sure you have a line like AddType application/x-httpd-php .php so that Apache knows when to use it. 您在Apache httpd.conf具有LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so ,因此Apache知道要使用PHP,但是需要确保您有一行类似于AddType application/x-httpd-php .php以便Apache知道何时使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM