A summary of the solution to the problem of Forbidden 403 in Apache service _linux

Source: Internet
Author: User
Tags chmod error code

In the configuration of the Linux Apache service, often encountered http403 error, I configure the test today also appeared, and finally resolved, summed up a bit. HTTP 403 error is a denial of access meaning, for a number of reasons. Also, these problems will happen in the win platform Apache! I have summarized the following 4 kinds of reasons according to the experience!

I test the environment is: Scientific Linux 5.3 (and Rhel and CentOS compatible!) , other versions of Linux should be generic and not tested.

1. Access to documentation is not sufficient. More than 755 permissions. WORKAROUND: Use the command chmod 755/var/www/or other appropriate directory.
2. SELinux or the cause of the firewall. Workaround: First turn off the SELinux and let the firewall through WWW service.
3. Virtual Host configuration error. For example, I met once:
Httpd.conf contains the configuration files for the virtual host:

Copy Code code as follows:

# Virtual Hosts
Include conf/extra/httpd-vhosts.conf

And conf/extra/httpd-vhosts.conf is not configured well, and the virtual host function has not been used for a while, so the include conf/extra/httpd-vhosts.conf commented out, restart Apache after normal.
WORKAROUND: Reconfigure the virtual host or temporarily shut down.

4. DocumentRoot settings. The workaround is as follows:

Open the Apache configuration file httpd.conf and find this code:

Copy Code code as follows:

<directory/>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Deny from all
</Directory>

Sometimes because of the configuration of PHP, this "deny from all" has rejected all connections. Change the line to "allow from all", the revised code is as follows, solve the problem.

Copy Code code as follows:

<directory/>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Allow from all
</Directory>

PS: I have not written the habit of technical log, later to share with you.

This is supplemented by other netizens:

Deployment Apache Service Forbidden 403 Issues Summary

Many friends and students have asked me the same question. Visit the website Forbidden 403 what reason? General Page tips are:

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

HTTP Error code 403:
403 Forbidden Resource is not available. The server understands the customer's request, but refuses to process it. This is usually caused by a permission setting on a file or directory on the server.

Usually, but not limited to, the reasons are:

Reason 1:apache There is no permission to the site directory in the configuration file, which is usually the case when you change the default Apache site directory after the initial installation of Apache (important, often):

If you change the site directory to:/var/blog, you will return a 403 error if you do not add the following configuration in the Apache configuration file.

<directory "/var/blog" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>

Tip: The configuration above the production environment needs to be modified, see below, only on the topic of this article to explain.


Reason 2: The site Directory does not have a home page file (index file), and Apache configuration and prohibit directory browsing, will be prompted 403 errors, configuration as follows (occasional):

A. The site directory does not have the first page file (index file):
[Root@http-server blog]# pwd
/var/blog
[Root@http-server blog]# LL
Total 12
Drwxr-xr-x 2 root root 4096 June 4 22:11 Oldboy
-rw-r--r--1 Root 0 June 4 22:11 oldboy.html
Hint: listed above is the site Directory/var/blog directory does not have a preset home directoryindex index.html

B.apache configuration disables three types of directory browsing
The first type of configuration:
<directory "/var/blog" >
Options-indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>

The second type of configuration:
<directory "/var/blog" >
Options FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>

The third type of configuration:
<directory "/var/blog" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>

Hint: The second reason friends occasionally friends, but the most problematic is the first reason.
========================================================
Detailed description of the above configuration:


===========================

Reason 3: Directory permissions issues (infrequently)

As follows: Deny 10.0.0.0/24 entire segment access. This denied host access will cause a 403 error
<directory "/var/blog" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
#Allow from all
Deny from 10.0.0.0/24


<directory "/var/blog" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
#Allow from all
Allow from 10.0.0.116
#Deny from 10.0.0.0/24
</Directory>

Reason 4: Site Directory permissions problem (infrequently).

The site Directory requires Apache users to have access rights, or you will report 403 errors.
[Root@http-server var]# pwd
/var
[Root@http-server var]# chown-r root.root blog/
[Root@http-server var]# chmod-Blog
[Root@http-server var]# ll-d blog/
drwx------3 root root 4096 June 4 22:11 blog/

This article for more reasons, look forward to your answer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.