Showing results for 
Search instead for 
Did you mean: 

Installing Magento in a subfolder i.e.,

Installing Magento in a subfolder i.e.,

Prerequisites were successfully installed. I installed Elastic Stack on Ubuntu 20.04 LTS. I followed all steps on this link (up to #2. Install and Configure Kibana on Ubuntu which I did not need). No problem whatsoever.

After installation is complete, I visited: and I got 403 Forbidden. I understand this is a permission issue, but before I installed Magento, I followed this guide and I set the permissions properly as highlighted below:



cd /var/www/html/<magento install directory>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data . # Ubuntu
chmod u+x bin/magento


When I first installed Magento 2, I was able to see it on the main domain without https and in the example/Magento directory. I think the problem is in my Nginx configuration file and more specifically in the SSL/ports which are as follows:


## Configure nginx for Magento 2
upstream fastcgi_backend {

   server   unix:/var/run/php/php7.4-fpm.sock;

server {

    root /var/www/;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;


    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php?$args; 

    # pass PHP scripts to FastCGI server
        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
        deny all;

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

} #closing server tag

## New block for magento
server {
listen 8080; 

    set $MAGE_ROOT /var/www/;

#    set $MAGE_MODE default;
    set $MAGE_MODE production;

    include /var/www/; 

# Set up a proxy
# source: 
include /etc/nginx/conf.d/*.conf;

server {
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80 ;
    listen [::]:80 ;

    return 404; # managed by Certbot


include /etc/nginx/conf.d/*.conf; is linked to a new file /etc/nginx/conf.d/magento_es_auth.conf with the following contents:

server {
   listen 8080;
   location /_cluster/health {
      proxy_pass http://localhost:9200/_cluster/health;

sudo nginx -t


nginx: [warn] conflicting server name "" on, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

SSL certificate renewal sudo certbot renew --dry-run passed!

Nginx.confi.sample includes this content: nginx.conf.sample 

How can I fix this and what went wrong?