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

     
Are you facing the "You don"t have sầu permission khổng lồ access on this server" error? Here are three ways to solve it in a jiffy.




Bạn đang xem: You don't have permission to access / on this server" error

no permission lớn access on this server
Many website hệ thống configurations face issues related lớn tệp tin permissions. It often renders the VPS inaccessible khổng lồ visitors & manifests in the khung of a 403 error. Usually, the error message is something lượt thích "Forbidden: you don"t have permission lớn access / on this server". This error can also restrict access to other routes on the server such as /directory.

Similar issues can also occur due to problems in the Apabít configuration file or even because of a corrupt .htaccess file. This guide provides step-by-step solutions khổng lồ all of these problems. Try them one at a time, starting from the first solution.


What Causes This Apache 403 Error?

This is a fairly common 403 error on Apache"s kết thúc caused by a myriad of issues. However, in most cases, this error occurs due lớn the lack of proper permissions needed lớn access a site publicly. Apart from this, WordPress sites often face this issue due to a bad .htaccess file.

Moreover, since Apabịt version 2.4, there have been some changes in how directives work. This can also restrict public access khổng lồ your website và result in a 403 forbidden error.


1. Fix File Permissions khổng lồ Avoid the Error

Most people face this comtháng 403 error due to lớn the laông xã of proper permissions. If the site admin forgets lớn enable read access khổng lồ the outside world, then end-users will be unable khổng lồ access the requested resource. This is often the root cause of this error.

If you"re a site admin instead, you need khổng lồ make sure files intended for public access have proper read permissions. Else, if you"re facing this error on a public site, insize the site administrator to lớn solve sầu this issue.


You don
Setting the correct permissions for publicly accessible files can be a bit tricky. That"s why admins should start with absolutely zero permissions và add them as needed. It"s a good idea lớn have folders with permission mode of 755 and files with 644.


For a simple trang web, the directories need lớn have execute permission, & files should have sầu read permission. Make sure not to lớn give exedễ thương permission on files. Malicious users can gain unwanted access lớn public servers via such files. The permission mode for Read, Write & Execute access is 4, 2, và 1, respectively.

So, a permission mode of 755 on directories means only the owner has full access lớn the directory contents. Group users & others can only read và exexinh tươi. Similarly, 644 permission mode for files provides read và write access to the owner và only read access lớn everyone else.


file permissions to solve sầu you don
To solve this error, fix your webroot directory permissions. The below commvà uses the chmod utility to lớn phối the directory permissions to 755.

suvị find /var/www/html -type d -exec chmod 755 ; This comm& assumes you"re using the mặc định document root of Apađậy lớn hold your website. If you"re using a different directory, replace the directory name accordingly. Use the below comm& lớn change all tệp tin permissions to 644.


suvị find /var/www/html -type f -exec chmod 644 ; The above comm& uses the find utility to lớn locate individual files và sets the correct permission via chgian lận. The ending holds the tệp tin paths returned by the find command, and the semicolon (;) marks the end of the iteration. Finally, restart the Apache VPS so your changes can take effect.

sudo systemctl restart apache2.service This comm& restarts the Apađậy hệ thống on Ubuntu. However, many RPM-based distros lượt thích RHEL or CentOS install Apabịt as httpd. For such systems, use the following command instead:

subởi systemctl restart httpd


Xem thêm: Xóa Các Phần Tử Trùng Nhau Trong Mảng, Xóa Các Phần Tử Trùng Trong Mảng 1 Chiều

2. Fix the .htaccess File for Your WordPress Website

The .htaccess file serves as a distributed config file and tells Apabịt how to lớn handle things like configuration changes per directory. Sometimes this tệp tin can get corrupted and may result in the "you don"t have sầu permission lớn access on this server" error.


Luckily, if that"s what is causing the 403 error on your hệ thống, you can easily fix this by creating a new .htaccess tệp tin. In order lớn create a new .htaccess tệp tin for your trang web, first, log in khổng lồ your WordPress dashboard. Then, clichồng on Settings > Permalinks.


permalinks update in wordpress site
You don"t have lớn make any additional changes here. Just click on the Save sầu Changes button and WordPress will generate a fresh .htaccess file for you.


pemalinks change in wordpress site
So anytime you face the above sầu problem, try creating a new .htaccess file. The .htaccess method usually works well for WordPress websites.


3. Configure Directives in the Apache Configuration File

Apache 2.4 makes use of a new configuration module named mod_authz_host. This module exposes several new directives. In short, this implements the following rules:


Require all granted: Allow all requests Require all denied: Deny all requests Require host safe.com: Only permit requests from safe.com

If you"re using Apabít 2.4, make sure your main configuration file contains the following blochồng of code. You can kiểm tra out the contents of this tệp tin using a simple text editor lượt thích Vyên ổn. Add this block in the configuration tệp tin if they"re missing. Then, you can save & exit Vyên ổn.

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 Moreover, if you"re running an RHEL-based web server, you need to ease access lớn the /var/www section in your Apabịt configuration file. So make sure 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 Apađậy hệ thống using one of the following commands.

# for Ubuntu & Debiansuvì chưng systemctl restart apache2.service# for RHEL & CentOSsuvày systemctl restart httpd

Fix the Apabịt Server Permission Error

A lot of people face the above sầu issue when accessing public websites or configuring their own sites. This guide covered several fixes khổng lồ this problem. Resetting the filesystem permission for Apache should be the first resort. If the error persists even after changing the permissions, try creating a new .htaccess file and ensure directives are set properly in your Apache configuration file.

There are many more issues that can result in a server-side error similar khổng lồ this one. You need to be proficient at troubleshooting Linux server issues lớn get your hệ thống up and running in such situations.


Fix Linux Server Issues With These 5 Troubleshooting Steps Get your Linux VPS bachồng up và running in minutes with these smart troubleshooting tips.


Chuyên mục: Domain Hosting