You do not have permission to access this server

0


Many web server configurations face issues with file permissions. This often makes the server inaccessible to visitors and manifests as a 403 error. Usually the error message is something like “Forbidden: you do not have permission to access / on this server” . This error can also restrict access to other routes on the server such as /phone book.

Similar issues can also occur due to issues in the Apache config file or even due to a .htaccess drop off. This guide provides step-by-step solutions to all of these problems. Try them one at a time, starting with the first solution.

What are the causes of this Apache 403 error?

This is a fairly common 403 error on the Apache side, caused by a myriad of issues. However, in most cases, this error occurs due to the lack of the proper permissions needed to publicly access a site. Apart from that, WordPress sites often face this problem due to a bad .htaccess drop off.

Additionally, since Apache version 2.4, there have been some changes in how directives work. It can also restrict public access to your website and result in a 403 forbidden error.

1. Correct file permissions to avoid error

Most people face this common 403 error due to lack of proper permissions. If the site administrator forgets to enable read access to the outside world, end users will not be able to access the requested resource. This is often the root cause of this error.

If you are more of a site administrator, you must ensure that files intended for public access have the correct read permissions. Otherwise, if you encounter this error on a public site, notify the site administrator to resolve this issue.

You do not have permission to access this server

Setting the correct permissions for publicly accessible files can be a bit tricky. Therefore, admins should start with absolutely zero permissions and add them as needed. It is a good idea to have files with the authorization mode of 755 and files with 644.

For a simple website, directories should have execute permission, and files must have Lily authorization. Make sure you don’t give execute permission on the files. Malicious users can gain unwanted access to public servers through such files. The authorization mode for Lily, Write and Execute access is 4, 2, and 1, respectively.

Thus, an authorization mode of 755 on directories means that only the owner has full access to the contents of the directory. Group users and others can only read and execute. Likewise, the 644 permission mode for files provides read and write access to the owner and only read access to everyone.

file permissions to resolve you have no access error

To resolve this error, correct the permissions for your web root directory. The command below uses the chmod utility to set directory permissions to 755.

sudo find /var/www/html -type d -exec chmod 755 {} ;

This command assumes that you are using Apache’s default document root to manage your website. If you are using a different directory, replace the directory name accordingly. Use the command below to change all file permissions to 644.

sudo find /var/www/html -type f -exec chmod 644 {} ;

The above command uses the find utility to locate individual files and sets the correct permission through chmod. The end {} contains the file paths returned by the find command, and the semicolon (;) marks the end of the iteration. Finally, restart the Apache server for your changes to take effect.

sudo systemctl restart apache2.service

This command restarts the Apache server on Ubuntu. However, many RPM based distributions like RHEL or CentOS install Apache as httpd. For such systems, use the following command instead:

sudo systemctl restart httpd

2. Correct the .htaccess file for your WordPress website

the .htaccess serves as a distributed configuration file and tells Apache how to handle things like directory configuration changes. Sometimes this file can get corrupted and result in the “you do not have permission to access this server” error.

Fortunately, if this is the cause of the 403 error on your server, you can easily fix it by creating a new .htaccess file. In order to create a new .htaccess file for your website, first log into your WordPress dashboard. Then click on Settings> Permalinks.

update of the permalink on the wordpress site

You don’t need to make any additional changes here. Just click on the Save changes and WordPress will generate a new .htaccess file for you.

change of pemalink in wordpress site

So whenever you encounter the above problem, try to create a new .htaccess file. The .htaccess method generally works well for WordPress websites.

3. Configure directives in the Apache configuration file

Apache 2.4 uses a new configuration module named mod_authz_host. This module outlines several new guidelines. In short, this implements the following rules:

  • Require everything granted: Allow all requests
  • Demand everything denied: Deny all requests
  • Require safe.com host: Only allow requests from safe.com

If you are using Apache 2.4, make sure your main configuration file contains the following block of code. You can check the contents of this file using a simple text editor like Vim. Add this block to the configuration file if they are missing. Then you can save and exit Vim.

vim /etc/apache2/apache2.conf

Options FollowSymLinks
AllowOverride None
Require all denied


AllowOverride None
Require all granted


Options Indexes FollowSymLinks
AllowOverride None
Require all granted

In addition, if you are running a RHEL-based web server, you should provide easy access to the / var / www section in your Apache configuration file. So make sure that the /etc/httpd/conf/httpd.conf file contains the following block of code.

vim /etc/httpd/conf/httpd.conf

AllowOverride None
Require all granted

Finally, restart the Apache server using one of the following commands.

# for Ubuntu and Debian
sudo systemctl restart apache2.service
# for RHEL and CentOS
sudo systemctl restart httpd

Correct the Apache server authorization error

Many people face the above problem when accessing public websites or setting up their own sites. This guide has covered several fixes for this issue. Resetting the file system authorization for Apache should be the first resort. If the error persists even after changing permissions, try creating a new one .htaccess and make sure the directives are set correctly in your Apache configuration file.

There are many other issues that can cause a server side error similar to this one. You must be proficient in troubleshooting Linux server problems in order for your server to be operational in such situations.


A laptop with coding
Troubleshoot Linux Server Problems With These 5 Troubleshooting Steps

Get your Linux server back up and running in minutes with these smart troubleshooting tips.

Read more


About the Author

.



Source link

Leave A Reply

Your email address will not be published.