During your Magento 2 development and other projects might get an error, such as 403 Forbidden Error which annoys you every time. Moreover, it can negatively impact on your online shop.
The error says:
“You don’t have permission to access .htaccess on this server”
You might spent hours debugging your apache2 configurations (httpd-vhosts.conf, user.conf, httpd.conf), file permissions, maximum allowed opened files in the system
Your initial guess might that system limits amount of files opened. That might you see in error (Too many files opened). You might increase this limit, however error do show again. Randomly.
Of course when you develop with Magento 2 having lots of files you might also think that it might not handle big amount of files. That might you thought.
Lets find out in this post with these following steps:
- Step 1: Find your username
- Step 2: Run Apache server
- Step 3: Check and uncomment
How to Fix 403 Forbidden Error in Magento 2?
Step 1: Find your user name
Firstly, you have to adjust permissions for user which is used to run localhost server in order to resolve the 403 Forbidden problem .
You might find your username with this command: whoami
Then if you have config for this user, you might navigate and check or if doesn’t exist, you might create:
Step 2: Run Apache server
You might used to run Apache server Where username is an user name.
Then you might add the following configuration :
sudo vi /etc/apache2/user/<username>.conf
Then you might add the following content:
And you can addLanguage en .en
LanguagePriority en fr de
Options FollowSymlinks Indexes MultiViews
Allow from localhost
Require all granted
Add lines in the /etc/apache2/httpd.conf configuration file:
sudo vi /etc/apache2/httpd.conf
Step 3: Check and uncomment
Finally, check and uncomment the line:
In the httpd-userdir.conf file ensure to uncomment line:
Restart Apache server
sudo /usr/sbin/httpd -k restart
Maybe the files will be overwritten when we will update Magento so you might keep notes of where to do the code changes again after future updates.
Visit our website for more information CartMigration