0

I have issue with Magento 2 + Nginx server. My magento 2 all website page is error "ERR_CONNECTION_REFUSED". Something wrong with my server configuration?

My server configuration


Path: /etc/nginx/conf.d/domain-name.conf

upstream fastcgi_backend {
    # socket
    # server unix:/var/run/php5-fpm.sock;
   server   unix:/var/run/php/php7.0-fpm.sock;
    # use tcp connection
    #  server  127.0.0.1:9000;

}
server {
    listen 80;
    server_name server-domain.com;
    return 301 $scheme://www.magento-website-domain.com$request_uri;
}

server {
    listen 80 reuseport;
    server_name server-domain.com;

    set $MAGE_ROOT /home/host-user/public_html;

   set $MAGE_MODE developer;
#    set $MAGE_MODE default;
#    set $MAGE_MODE production;

    include /home/host-user/public_html/nginx.conf.sample;
    fastcgi_read_timeout 3000;
}

Path: /etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

(/var/log/nginx/error.log) log file can see notification

"/home/host-user/public_html/index.php" failed (13: Permission denied), client: 127.0.0.1, server: server-domain.com, request: "GET /whm-server-status HTTP/1.0"

I have permission for file index.php 644 but same error?

1
  • Try changing this set $MAGE_ROOT /home/host-user/public_html to this set $MAGE_ROOT /home/host-user/public_html/pub/ Dec 8, 2020 at 12:59

1 Answer 1

0

It's a little difficult to provide a precise answer in this case as there is not enough information provided, specifically about the environment. Magento 2 besides just NGINX has a whole list of requirements which need to be followed to make it work.

https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html#php

Specific to your case:

in /etc/nginx/conf.d/domain-name.conf #1 server unix:/var/run/php/php7.0-fpm.sock; php7.0 most likely won't work, refer to Magento requirement posted above.

#2 set $MAGE_MODE developer; It's better if that is set inside include /home/host-user/public_html/nginx.conf.sample; I also copy and rename nginx.conf.sample to nginx.conf as after any magento update that file will get overwritten and you will have to modify it again.

#3 Magento 2 besides NGINX and PHP also requires a whole set of Required PHP extensions, which again can be found in the requirements link. Without those you'll see error and it won't work.

First make sure that all the requirements are met, then we can troubleshoot further. Not it seems you don't yet have what Magento requires.

Your Answer

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

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