15

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>
Ehphan
  • 537
  • 3
  • 7
  • 19

12 Answers12

25

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

Reddi Rajendra P
  • 704
  • 9
  • 25
11

Set SELinux in Permissive Mode using the command below:

setenforce 0;
Pratik Patil
  • 3,662
  • 3
  • 31
  • 31
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

Shaun Hare
  • 3,771
  • 2
  • 24
  • 36
  • Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all – Ehphan Jul 03 '13 at 08:03
  • does it work locally - if you target localhost on the machine itself If only cli try with curl – Shaun Hare Jul 03 '13 at 08:07
  • I don't have local access to centos server – Ehphan Jul 03 '13 at 08:08
  • Ah OK - so is the issue with the internal firewall have you 80 open in iptables? – Shaun Hare Jul 03 '13 at 10:34
  • I've added the line "-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT" in /etc/sysconfig/iptables and then restarted iptables. It restarted OK but still same FORBIDDEN error when trying to access from outside. – Ehphan Jul 03 '13 at 11:19
2

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.

jabaldonedo
  • 25,822
  • 8
  • 77
  • 77
  • I don't have local access to centos, but I did SELINUX thing and It's still same errors!! – Ehphan Jul 03 '13 at 08:11
  • have you tried to do `wget localhost` from centos console and then check with a text editor the response? – jabaldonedo Jul 03 '13 at 08:19
  • I did that and it works ok, content of localhost (index.html) is equal to one in server. – Ehphan Jul 03 '13 at 08:30
  • 1
    I think you can just use `setsebool -P httpd_enable_homedirs true` instead of disabling the SELinux – nyxz Feb 19 '14 at 17:01
2

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

nohack
  • 21
  • 1
1

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

sebasdev
  • 309
  • 3
  • 8
0

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

David Jashi
  • 4,490
  • 1
  • 21
  • 26
0

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

Mwangi Njuguna
  • 75
  • 2
  • 10
0

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
Mike
  • 439
  • 1
  • 6
  • 10
0

try to edit httpd.conf

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

For CentOS 8 your /etc/httpd/conf.d/awstats.conf file needs to look like this and you need to stick in your IP address and restart your httpd service unless you want to whole world to have access to it!

#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/share/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats/wwwroot">
    Options None
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAny>
           Require <Your IP Address here>
        </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Allow from <Your IP address here>
        Allow from ::1
    </IfModule>
</Directory>
# Additional Perl modules
<IfModule mod_env.c>
    SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>

Remember that if you IP address changes you need to update the file and restart the httpd server. BTW you can see your ip address as it looks from the outside by simply googling "my ip"

Anthony
  • 575
  • 6
  • 8
-1

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