apache不解析php 出现空白页面?

回复 收藏
本帖最后由 笨魚1979 于 2014-10-13 19:52 编辑

按正确步骤安装的,可以正常访问html页面。
00.jpg

这是没配置 AddType application/x-httpd-php .php 时能访问的页面
1.能访问html页面
01.jpg

2.不解析PHP文件

02.jpg

加入AddType application/x-httpd-php .php后
03.jpg

访问PHP页面时,什么也不显示,是空白的!?
04.jpg

参看空白页面的源码是这样的
05.jpg


不知道是什么原因造成的,该如何配置?希望给予解答!

重新编译PHP,发现没成功
1.配置
./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6
php配置成功.jpg

配置成功!

2.编译
make && make install
PHP编译时出错.jpg

这里出错了!!!
2014-10-12 23:46 举报
已邀请:
0

阿铭 管理员

赞同来自:

php不解析的排查步骤:
1. /usr/local/apache2/bin/apachectl -M 看一下有没有加载libphp5.so
2. 查看配置文件中是否有
AddType application/x-httpd-php .php
3. 看看有没有加入index

    DirectoryIndex index.html index.htm index.php

4. 不要忘记重启apache
5. 还有一个不容忽视的问题,就是检查你的selinux是否开启
命令: getenforce 如果结果是 Enforcing 就说明是打开的
关闭: setenforce 0
还要在配置文件中配置一下 vi  /etc/selinux/config  把enforcing改为disabled

在测试的时候,可以在你的linux本机上测试  curl localhost/phpinfo.php   -I  看下状态码,看是否是200
0

寻@轨迹

赞同来自:

貌似你的php语法错误吧
0

笨魚1979

赞同来自:

[root@CentOS_65_Mini ~]# curl localhost/phpinfo.php -I
HTTP/1.1 200 OK
Date: Mon, 13 Oct 2014 11:20:25 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
X-Powered-By: PHP/5.3.28
Content-Type: text/html
1

寻@轨迹

赞同来自: 不可撤销

phpinfo();
?>
0

雷老师 管理员

赞同来自:

楼上正解{:4_91:}
0

笨魚1979

赞同来自:

寻@轨迹 发表于 2014-10-13 19:15
貌似你的php语法错误吧

说的太对了!是PHP的语法写错了!应该是而我写成啦!
之前写写习惯了,没意识到啊!还一直以为是Apache、php配置的问题!
太感谢了!{:7_184:}
0

戎强

赞同来自:

..
0

s9308

赞同来自:

{:4_118:}
0

君君

赞同来自:

[root@ip111 htdocs]# curl localhost/phpinfo.php   -I  
HTTP/1.1 404 Not Found
Date: Tue, 08 Dec 2015 14:30:35 GMT
Server: Apache/2.2.31 (Unix) PHP/5.4.44
Content-Type: text/html; charset=iso-8859-1

为什么我的是HTTP/1.1 404 Not Found ???
1

周振涛

赞同来自: 不可撤销

apache我觉得有必要都搞懂报错编码的意思  不少人会为此走不少弯路
0

wildfire

赞同来自:

学习了。
0

m.chang

赞同来自:

笨魚1979 发表于 2014-10-14 21:48
说的太对了!是PHP的语法写错了!应该是而我写成啦!
之前写写习惯了,没意识到啊!还一直以为是Apache ...

我学到这里的时候也范过类似的错误。嘿嘿。{:4_95:}
0

易心易意

赞同来自:

今天安装Discuz报错462,不知道怎么解决
0

044310

赞同来自:

这个要好好看看啊
0

yangguang_tu

赞同来自:

1. /usr/local/apache2/bin/apachectl -M 看一下有没有加载libphp5.so
发现这一步有问题应该怎么解决啊?
0

13258221382

赞同来自:

君君 发表于 2015-12-8 22:34
[root@ip111 htdocs]# curl localhost/phpinfo.php   -I  
HTTP/1.1 404 Not Found
Date: Tue, 08 Dec 20 ...

我的也是这个问题,你解决了吗
0

guyuetom

赞同来自:

阿铭 发表于 2014-10-13 13:56
php不解析的排查步骤:
1. /usr/local/apache2/bin/apachectl -M 看一下有没有加载libphp5.so
2. 查看配 ...

阿铭老师,我运行apachectl -M 没有libphp5.so这个模块,但是PHP不会报错,这个模块的作用是什么呢?
[root@localhost ~]# /usr/local/apache2/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
php5_module (shared)

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: