I'm new to Magento. I have installed Magento in the sub folder on the server.

created DB successfully.

But, when I run URL on the browser it gives the error that

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

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

  • you do not provide any details about your server or web server software, but this sounds like the website root folder is not configured to point to your magento2 installation correctly.
    – paj
    Jun 13, 2017 at 20:36

3 Answers 3


Could you please check the file and folder permission as given in Magento Docs

Files and Folder Permission in Magento 2

Also Please check in your server for mod_rewrite is enabled in Apache2

  • how can i check? Jun 13, 2017 at 18:14
  • Which OS are you using ?
    – Suresh S
    Jun 14, 2017 at 1:39
  • you can check it through command "sudo a2enmod rewrite". also check in apache configuration file . open the configuration file check the following line <Directory /var/www/>. Please make sure that "AllowOverride All". then save and restart the apache.
    – Suresh S
    Jun 14, 2017 at 1:48
  • i am using window 7 Jun 16, 2017 at 8:31
  • are you using XAMPP or any other instance where magento is running?
    – Suresh S
    Jun 16, 2017 at 10:23

----------Windows configuration ----------------- XAMPP > XAMPP Control Panel > apache config setting

xampp\apache2\conf\httpd.conf open this

#LoadModule rewrite_module modules/mod_rewrite.so

Remove # tag for uncomment.

/xampp/apache/conf/extra/httpd-vhost.conf open this.

Create an virtual host

  DocumentRoot "C:/path/to/your/site"
  ServerName example.local

  CustomLog "C:/path/to/your/site/logs/example.local.access.log" combined
  ErrorLog "C:/path/to/your/site/logs/example.local.error.log"

  <Directory "C:/path/to/your/site">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

Restart server once.


::: For Apache2 :::

Create Virtual Host

Login with sudo command in the terminal by typing

sudo -s

Create a virtual host file.

sudo touch /etc/apache2/sites-available/<site-name>.conf
sudo nano /etc/apache2/sites-available/<site-name>.conf

Paste Below Code into it. Change php version and domain name as per the requirement + verify the directories.

<VirtualHost *:80>
ServerAdmin admin@<domain-name>
ServerName domain-name
ServerAlias www.domain-name
ServerAdmin webmaster@domain-name
 DocumentRoot /var/www/html/domain-name/pub
<Directory /var/www/html/domain-name>
Options -Indexes +FollowSymLinks
AllowOverride All
<FilesMatch \.php$>
      SetHandler "proxy:unix:/run/php/php<php-version>-fpm.sock|fcgi://localhost"

Hit below commands over the terminal

sudo a2ensite <site-name>.conf
sudo apachectl configtest
sudo systemctl restart apache2

Make an entry of the domain name.

nano /etc/hosts

Paste this right at the bottom    <site-name>

To Disable Site Configuration

sudo a2dissite <site-name>.conf
sudo systemctl restart apache2

:::: ::::

::: For Nginx :::

Create Virtual Host Login with sudo command in the terminal by typing

sudo -s

Create a virtual host file.

sudo touch /etc/nginx/sites-available/<site-name>.conf
sudo nano /etc/nginx/sites-available/<site-name>.conf

Paste Below Code into it.

upstream fastcgi_backend {
  server  unix:/run/php/php7.4-fpm.sock;

server {
  listen 80;
  server_name <site-name> www.<site-name>;
  set $MAGE_ROOT /var/www/html/<site-name>;
  include /var/www/html/<site-name>/nginx.conf.sample;

Fire below command on terminal and restart nginx. It’ll be working then.

sudo ln -s /etc/nginx/sites-available/<site-name>.conf /etc/nginx/sites-enabled/

::: :::

::: Setup Permissions ::: Always Remember to look at the directory first and then fire below commands.

cd <magento-root-dir>

chmod -R uog-rwxs .
chown -R <file-owner> .
chgrp -R <apache-running-user-group> .
find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 755 {} +
find var/ pub/static pub/media app/etc generated/ -type f -exec chmod g+w {} +
find var/ pub/static pub/media app/etc generated/ -type d -exec chmod g+ws {} +
chmod 640 app/etc/env.php
chmod -R g+s .

<apache-running-user-group> will be most probably www-data To see by which user and group apache2 is running, type below command on the terminal.

apachectl -S

If XDebug is not working, one may try changing below configuration

nano /etc/php/7.4/fpm/pool.d/www.conf

& Update below configuration as per above screenshot you achieved.

user = <file-owner>
group = www-data
listen.owner = <file-owner>
listen.group = www-data

::: :::

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.