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

拜拜、爱过 提交于 2019-12-18 01:15:14

问题


I have CentOS 6.1 server and I installed apache 2.2.15 on it. Now When I try to access it from another pc (windows 7) from IE (http:/// (=centos ip)) I get the "You don't have permission to access / on this server." error. I even created phpinfo.php file with content of "" on "var/www/html" and when I try to access it by using "http://*/phpinfo.php" in IE, I get not found error. What should I do? my httpd.conf for directiry is like this:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

回答1:


Edit httpd.conf file, which is in /etc/httpd/conf/httpd.conf. Add the below code.

<Directory "/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>

<Directory "/home/">
 #Options FollowSymLinks
 Options Indexes FollowSymLinks Includes ExecCGI
 AllowOverride None
 Allow from all
</Directory>

After the line no. 555 (in my case) . Check for the file permissions and restart the server.

service httpd restart   

Now, it will work . Still you are facing the same problem, disable the seLinux in /etc/selinux/config change SELINUX=disabled and restart the server as mentioned above and try it.

Hope this helps




回答2:


Set SELinux in Permissive Mode using the command below:

setenforce 0;



回答3:


Check file permissions of the /var/www/html and the ALLOW directive in your apache conf

Make sure all files are readable by the webserver and the allow directive is like

 <Directory "/var/www/html">
    Order allow,deny
    Allow from all
  </Directory>

if you can see files then consider sorting the directive to be more restrictive




回答4:


Fist check that apache is running. service httpd restart for restarting

CentOS 6 comes with SELinux activated, so, either change the policy or disabled it by editing /etc/sysconfig/selinux setting SELINUX=disabled. Then restart

Then check locally (from centos) if apache is working.




回答5:


Try to use the following: chmod +rx /home/*




回答6:


Create index.html or index.php file in root directory (in your case - /var/www/html, as @jabaldonedo mentioned)




回答7:


Right click your www folder and click on properties. Navigate to permissions and change all to read and write then click on "Apply permission to enclosed files" and your are done!! Maybe its too late but this will definitely help some other person




回答8:


Check the apache User and Group setting in the httpd.conf. It should default to apache on AMI/RedHat or www-data on Debian.

grep '^Group\|^User' /etc/httpd/conf/httpd.conf

Then add the apache user to the group setting of your site's root directory.

sudo usermod -a -G <your-site-root-dir-group> apache



回答9:


If you set SELinux in permissive mode (command setenforce 0) and it works (worked for me) then you can run restorecon (sudo restorecon -Rv /var/www/html/) which set the correct context to the files in Apache directory permanently because setenforce is temporal. The context for Apache is httpd_sys_content_t and you can verify it running the command ls -Z /var/www/html/ that outputs something like:

-rwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 index.html

In case the file does not have the right context, appear something like this:

drwxr-xr-x. root root unconfined_u:object_r:user_home_t:s0 tests

Hope it can help you.

PD: excuse me my English




回答10:


try to edit httpd.conf

<Directory "/usr/local/www/apache24/cgi-bin">
  Options Indexes FollowSymLinks Includes ExecCGI
  Require all granted
</Directory> 



回答11:


Set required all granted in /etc/httpd/conf/httpd.conf



来源:https://stackoverflow.com/questions/17442370/you-dont-have-permission-to-access-on-this-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!