Skip to content

Permission denied error when trying to access magento2 prior to installation on Ubuntu 20.04 / nginx / php 7.4

What I’ve done so far,

Installed nginx 1.19.6
Installed php 7.4 and all required extensions in Magento Documentation
Installed and configured MySQL as per documentation, and created magentodb
Installed Elasticsearch 7.x (Success)
Installed Redis-server (Success)
DID NOT install Varnish since the Magento documentation states that it does not support SSL and I can’t run my magento store without SSL.

Downloaded Magento 2.4.1 Community edition with sample data
Moved to the chosen root directory @ /var/www/

Created Non-root sudo user, and carefully provided all the necessary permissions.

Usually, I get a magento welcome page like this one:
enter image description here

But this time, i rebuilt my whole droplet making sure i didn’t miss any of the details that caused me errors before. This time I’m getting an “Unable to connect” error in my browser, and sending a GET request from terminal is returning the below error.

curl -XGET ‘https://mydomain/’

curl: (7) Failed to connect to mydomain port 443: Connection refused

ping to mydomain successfully points to my cloud IP address

PING mydomain (ipv4-xxx-xx-xxx) 56(84) bytes of data.
64 bytes from ipv4-xxx-xx-xxx (ipv4.xxx.xx.xx): icmp_seq=1 ttl=53 time=167 ms

GET Request to my localhost on my server successfully returns the Nginx welcome page:

 curl -XGET 'localhost'
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>

Does anyone have a hint where to go from here?

@samuel-demir

Update: I am running Magento 2.4.1 Community Edition

Nginx Status

Active: active (running) since Fri 2021-01-22 19:26:03 UTC; 15h ago

Nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 

PHP7.4-FPM status

Active: active (running) since Fri 2021-01-22 18:49:59 UTC; 16h ago 

Didn’t install varnish since the Magento Docs state that it doesn’t support SSL.

Yes my configuration file is symlinked to /sites-enabled/

This is my /sites-available/* config file

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

server {
    listen 80;
    listen [::]:80;
    server_name mydomain;
    return 301 https://$server_name$request_uri;
}

server {

        listen 443 ssl;
        server_name mydomain;

        ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;

        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE default;
        include /var/www/magento2/nginx.conf.sample;
}

Also, I have UFW enabled with the following allowed connections

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 443/tcp                    ALLOW IN    Anywhere                  
[ 2] 22/tcp                     ALLOW IN    Anywhere                  
[ 3] 443/tcp (v6)               ALLOW IN    Anywhere (v6)             
[ 4] 22/tcp (v6)                ALLOW IN    Anywhere (v6)