本帖最后由 笨魚1979 于 2014-10-13 19:52 编辑
按正确步骤安装的,可以正常访问html页面。
这是没配置 AddType application/x-httpd-php .php 时能访问的页面
1.能访问html页面
2.不解析PHP文件
加入AddType application/x-httpd-php .php后
访问PHP页面时,什么也不显示,是空白的!?
参看空白页面的源码是这样的
不知道是什么原因造成的,该如何配置?希望给予解答!
重新编译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
配置成功!
2.编译
make && make install
这里出错了!!!
按正确步骤安装的,可以正常访问html页面。
这是没配置 AddType application/x-httpd-php .php 时能访问的页面
1.能访问html页面
2.不解析PHP文件
加入AddType application/x-httpd-php .php后
访问PHP页面时,什么也不显示,是空白的!?
参看空白页面的源码是这样的
不知道是什么原因造成的,该如何配置?希望给予解答!
重新编译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
配置成功!
2.编译
make && make install
这里出错了!!!
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
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
[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
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
0
说的太对了!是PHP的语法写错了!应该是而我写成啦!
之前写 ?>写习惯了,没意识到啊!还一直以为是Apache、php配置的问题!
太感谢了!{:7_184:}
寻@轨迹 发表于 2014-10-13 19:15
貌似你的php语法错误吧
说的太对了!是PHP的语法写错了!应该是而我写成啦!
之前写 ?>写习惯了,没意识到啊!还一直以为是Apache、php配置的问题!
太感谢了!{:7_184:}
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 ???
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 ???
0
我学到这里的时候也范过类似的错误。嘿嘿。{:4_95:}
笨魚1979 发表于 2014-10-14 21:48
说的太对了!是PHP的语法写错了!应该是而我写成啦!
之前写写习惯了,没意识到啊!还一直以为是Apache ...
我学到这里的时候也范过类似的错误。嘿嘿。{:4_95:}
0
我的也是这个问题,你解决了吗
君君 发表于 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
阿铭老师,我运行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)
阿铭 发表于 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)
编辑回复