Centos下Apache访问网站根目录下子目录出现You don't have permission to access错误的解决办法

来源:互联网 发布:淘宝wap访客是什么意思 编辑:程序博客网 时间:2024/06/05 23:00

检查http.conf发现没错之后,查找资料后发现时selinux的问题,所以需要关闭这个服务:

1vi /etc/sysconfig/selinux
2SELINUX=enforcing 改为 SELINUX=disabled

重启后生效

不需重启 执行命令:

1setenforce 0
*********************************************************

在CentOS5.3+MySQL 5.0.45 +Apache2.2.3 +PHP5.1.6中运行PHP程序出错

You don't have permission to access / on this server

装好apache+php+mysql后,
拷贝一份phpmyadmin过后运行出错:
You don't have permission to access / on this server

有人说把selinux关掉就好了

而我发现了这个原因和方法:
因为网站执行的权限,一般要Read from all httpd scripts and the daemon这个权限。

当系统内经过解压出来的文件夹是没有这个权限的。

我们要在html/下新建一个目录(这时会自动分为Read from all httpd scripts and the daemon权限)

然后把档案复制一份过来放进去(注意不是剪切)

运行试试看吧。

我就可以了。

CentOS5.3+MySQL 5.0.45 +Apache2.2.3 +PHP5.1.6(都是系统自带的)

*********************************************************

在终端输入   (更改网站根目录权限为755,很多centos系统默认为700)

[root@localhost ~]#   chmod  -R 755 /var/www/html/                     

然后重启

[root@localhost ~]#   /etc/init.d/httpd restart


*********************************************************

打开apache的配置文件httpd.conf,逐行检查。在大约快一半的地方有以下这段代码:

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

发现了吧。由于配置了php后,这里的“Deny from all”已经拒绝了一切连接。把该行改成“allow from all”,修改后的代码如下,问题解决。

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    allow from all

系统是centos,You don't have permission to access / on this server.
在google上搜索了一下,大部分的解决方法就是。
 
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

这里改成

   Options Indexes FollowSymLinks
    AllowOverride None

我改了之后还是会出现上面的错误,于是看一下自己设定的工作目录权限。
Options ExecCGI Includes
改成下面这行设置后,显示正常。
 
Options Indexes FollowSymLinks
当访问类unix操作系统上的/usr/local/apache2/htdocs/foo/bar.htm文件时,你收到了Permission Denied的错误。

首先,查看文件的访问权限:

$ cd /usr/local/apache2/htdocs/foo
$ ls -l bar.htm

如果须要的话,就修复它们:

$ chmod 644 bar.html
对文件夹以及每个父文件夹做相同的操作
 
(/usr/local/apache2/htdocs/foo,/usr/local/apache2/htdocs,/usr/local/apache2,/usr/local/,/usr):
$ ls -la
$ chmod +x
$ cd ..
$ #repeat up to the root
在一些系统上,可使用工具namei来列出各个路径上的不同组件的访问权限,然后去发现是否有权限问题:
 
$ namei -m /usr/local/apache2/htdocs/foo/bar.html
0 0
原创粉丝点击