How to solve apache 403 forbidden?
apache httpd server 403 forbidden problem
1. Problem description
In the httpd configuration of apache2 , 403 will appear in many situations.
Just installed the httpd service, of course there will be no 403 problem. It mainly occurred after modifying some configurations. The problem is described as follows:
After modifying the DocumentRoot directory pointing, a 403 error occurred on the site.
Setting up a virtual host directory may also cause 403.
Apache's httpd service started successfully. It looks normal, but it does not have permission to access.
The log appears: access to / denied (filesystem path '/srv/lxyproject/wsgi/django.wsgi ') because search permissions are missing on a component of the path
After setting the virtual directory, the error log appears: client denied by server configuration: /srv/lxyproject/wsgi/django.wsgi
2. Analysis of problems and solutions
Pay attention to the error log content when solving the problem step by step below. OK, start.
1. Directory configuration file in httpd.conf
If it shows that the DocumentRoot has been changed, for example, it is changed to "/usr/local/site/test". The site directory and test directory are created by using mkdir, and then an index.html is placed under the test directory. In this case, you should check the configuration in httpd.conf.
Your
<Directory "/usr/local/site/test"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Require all granted </Directory>
2. Directory access permissions
The first step is correct if the configuration is still 403, check whether there is Deny from in the directory configuration
Can be set to Allow from all or Require all granted to process.
Do not modify Deny from all in the root directory of
3. Directory permissions
If it is still 403, it may be a permission issue with the website directory.
Apache requires the directory to have execution permissions, which is x. It should be noted that your directory tree should have these permissions.
If your directory is /usr/local/site/test, then ensure the four levels of /usr, /usr/local, /usr/local/site, /usr/local/site/test All directories have 755 permissions.
#chmod 755 /usr/local/site #chmod 755 /usr/local/site/test
One mistake I made was that I only set the last-level directory permissions and did not set the upper-level directory permissions, resulting in 403.
4. Virtual Directory
[I have never encountered this problem, because I have never written it like this. The online information says this, which can be used as a reference]
If it is set is a virtual directory, then you need to define a virtual directory in httpd.conf, and it looks like the following fragment:
Alias /folder "/usr/local/folder" <Directory "/usr/local/folder"> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.1 192.168.1.1 </Directory>
If this is the case, and you write something similar to my code above, three Every folder is the same, it will definitely be 403! How to solve it is to change the string after the slash after Alias. Change it to something that does not have the same name as the folder of the virtual directory. Then I can use the changed virtual directory to access it. Of course, change it. Folders are also OK, as long as you are not afraid of trouble and as long as the virtual directory definition characters (red) behind Alias and the actual folder name (black) are different, it will be OK.
5. Selinux problem
If it is still 403, then selinux is causing trouble. Therefore, you can set the selinux permissions on your directory.
I encountered this problem today.
#chcon -R -t httpd_sys_content_t /usr/local/site #chcon -R -t httpd_sys_content_t /usr/local/site/test
Online information says that most of this step will not happen. But my problem is indeed that it may be related to the system, and I don’t quite understand the specific principle.
6. Problems with wsgi
My virtual host configuration is:
<VirtualHost *:80> WSGIScriptAlias / /srv/lxyproject/wsgi/django.wsgi Alias /static/ /srv/lxyproject/collectedstatic/ ServerName 10.1.101.31 #ServerName example.com #ServerAlias www.example.com <Directory /srv/lxyproject/collectedstatic> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <Directory /srv/lxyproject/wsgi/> Allow from all </Directory> ErrorLog /etc/httpd/logs/lxyproject.error.log LogLevel warn </VirtualHost>
I access the
log error:
client denied by server configuration: /srv/lxyproject/wsgi/django.wsgi
Solution Method:
Modify Allow from all in
This problem is due to the version.
My httpd version is:
[root@yl-web conf.d]# rpm -qa |grep httpd httpd-devel-2.4.6-31.el7.centos.x86_64 httpd-tools-2.4.6-31.el7.centos.x86_64 httpd-2.4.6-31.el7.centos.x86_64
For versions below 2.3, use Allow from all, and for versions 2.3 and above, use Require all granted. .
<Directory /home/aettool/aet/apache> <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory>
The above is the detailed content of How to solve apache 403 forbidden. For more information, please follow other related articles on the PHP Chinese website!

The core function of Apache is modular design and high customization, allowing it to meet various web service needs. 1. Modular design allows for extended functions by loading different modules. 2. Supports multiple operating systems and is suitable for different environments. 3. Multi-process, multi-threaded and event-driven models improve performance. 4. The basic usage includes configuring the virtual host and document root directory. 5. Advanced usage involves URL rewriting, load balancing and reverse proxying. 6. Common errors can be debugged through syntax checking and log analysis. 7. Performance optimization includes adjusting MPM settings and enabling cache.

What makes Apache still popular in modern web environments is its powerful capabilities and flexibility. 1) Modular design allows custom functions such as security certification and load balancing. 2) Support multiple operating systems to enhance popularity. 3) Efficiently handle concurrent requests, suitable for various application scenarios.

The reasons why Apache has developed from an open source project to an industry standard include: 1) community-driven, attracting global developers to participate; 2) standardization and compatibility, complying with Internet standards; 3) business support and ecosystem, and obtaining enterprise-level market support.

Apache's impact on Webhosting is mainly reflected in its open source features, powerful capabilities and flexibility. 1) Open source features lower the threshold for Webhosting. 2) Powerful features and flexibility make it the first choice for large websites and businesses. 3) The virtual host function saves costs. Although performance may decline in high concurrency conditions, Apache remains competitive through continuous optimization.

Originally originated in 1995, Apache was created by a group of developers to improve the NCSAHTTPd server and become the most widely used web server in the world. 1. Originated in 1995, it aims to improve the NCSAHTTPd server. 2. Define the Web server standards and promote the development of the open source movement. 3. It has nurtured important sub-projects such as Tomcat and Kafka. 4. Facing the challenges of cloud computing and container technology, we will focus on integrating with cloud-native technologies in the future.

Apache has shaped the Internet by providing a stable web server infrastructure, promoting open source culture and incubating important projects. 1) Apache provides a stable web server infrastructure and promotes innovation in web technology. 2) Apache has promoted the development of open source culture, and ASF has incubated important projects such as Hadoop and Kafka. 3) Despite the performance challenges, Apache's future is still full of hope, and ASF continues to launch new technologies.

Since its creation by volunteers in 1995, ApacheHTTPServer has had a profound impact on the web server field. 1. It originates from dissatisfaction with NCSAHTTPd and provides more stable and reliable services. 2. The establishment of the Apache Software Foundation marks its transformation into an ecosystem. 3. Its modular design and security enhance the flexibility and security of the web server. 4. Despite the decline in market share, Apache is still closely linked to modern web technologies. 5. Through configuration optimization and caching, Apache improves performance. 6. Error logs and debug mode help solve common problems.

ApacheHTTPServer continues to efficiently serve Web content in modern Internet environments through modular design, virtual hosting functions and performance optimization. 1) Modular design allows adding functions such as URL rewriting to improve website SEO performance. 2) Virtual hosting function hosts multiple websites on one server, saving costs and simplifying management. 3) Through multi-threading and caching optimization, Apache can handle a large number of concurrent connections, improving response speed and user experience.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools
