本帖最后由 lanhaide 于 2014-01-09 23:00:58 编辑

解决方案 »

  1.   

    确定你php环境没问题? $ php -v
      

  2.   

    没问题啊。如果我在默认的/var/www/html下创建php文件,是可以运行的。
      

  3.   

    你现在在www/html/ 下新建 index.php
    <?php
    echo phpinfo();
    ?>
    运行有报错?至于你说的403,$ ll .../www/
    贴出结果看看或者在配置文件中找到下面两句user deamon
    group deamon因为这两句的存在,使得apache并没有权限去读写当前用户的目录,所以会出现权限问题把它们改为
    user currentUser (其中 currentUser 是当前用户的用户名)
    group currentGroup (其中 currentGroup 是当前用户所在的组名 如不知道 可用命令 groups "当前用户名" 来查询)
      

  4.   

    还是不行。按你的步骤走了一遍,现在的情况是地址栏输入localhost可以显示apache默认测试页面(原来不显示),但输入localhost/index.html或index.php仍然报403 forbidden错误。现在的文件结构如下:
    [root@localhost lanhyde]# ll www
    总用量 4
    drwxr-xr-x. 2 lanhyde lanhyde 4096 1月  13 14:09 html
    [root@localhost lanhyde]# cd www
    [root@localhost html]$ ls -Z
    -rw-rw-r--. lanhyde lanhyde unconfined_u:object_r:httpd_sys_content_t:s0 index.php
    -rw-rw-r--. lanhyde lanhyde unconfined_u:object_r:httpd_sys_content_t:s0 index.php~
    -rw-r--r--. root    root    unconfined_u:object_r:httpd_sys_content_t:s0 log.txt
    -rwxr-xr-x. root    root    unconfined_u:object_r:httpd_sys_content_t:s0 mypol.pp
    -rwxr-xr-x. root    root    unconfined_u:object_r:httpd_sys_content_t:s0 mypol.te
    [lanhyde@localhost html]$ ll
    总用量 16
    -rw-rw-r--. 1 lanhyde lanhyde   20 1月  13 14:18 index.php
    -rw-rw-r--. 1 lanhyde lanhyde    0 1月  13 14:18 index.php~
    -rw-r--r--. 1 root    root    1278 1月  13 13:58 log.txt
    -rwxr-xr-x. 1 root    root     939 1月  13 14:02 mypol.pp
    -rwxr-xr-x. 1 root    root     219 1月  13 14:02 mypol.te
      

  5.   

    -rw-rw-r--. 1 lanhyde lanhyde   20 1月  13 14:18 index.php
    更改
    chmod 755 file or chmod 777 file试试
    -rwxr-xr-x  1 root root     
    -rwxrwxrwx  1 root root      
      

  6.   

    试过了,不管用
    贴出你操作之后的效果。
    抱歉这么久才回复。使用其它网站提供的资料,我已经解决问题了。还是非常谢谢你哈。贴出我的参考地址为有相同问题的童鞋提供点帮助:http://www.if-not-true-then-false.com/2010/enable-apache-userdir-with-selinux-on-fedora-centos-red-hat-rhel/