selinux又作怪,致使php程序web上出奇怪的问题

在FC4(fedora core 4)下

httpd2.0.54+php5

测一个巨简单的php程序

[root@sohu steps]# cat test.php

<?php

if(file_exists("/www/config.php")) {

        if (($o = fopen("/www/config.php", "w")) == TRUE) {

                print "OK";

        } else {

                print "pei";

        }

}

?>

在web页面上看始终是显示“pei”

在本机命令行用php test.php来看

始终显示"OK"

而且用跑httpd的apache的身份来执行php test.php也显示"OK"

而且php.ini文件也没有什么问题

是在是不明白了



最后

想想会不会是selinux搞的鬼呢

于是

死马当活马医

setenforce 0

(这个命令是用来disable掉selinux的)

再一试

居然好了!!

One Response to “selinux又作怪,致使php程序web上出奇怪的问题”

  1. selinux还是有点用的吧/简单的关闭并不是最终解决办法。

Discussion Area - Leave a Comment




*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word