HELP connection refused wordpres and nginx

May 3, 2019 261 views
WordPress PHP Nginx Ubuntu

Hi! I’ve got this error, and it’s very complicated to solve it, I’ve got two wordpress installations in my droplet and it will be the third. I’ve got the same configuration (With different root route and server names) in the server and this third installation doesn’t work. The error_log in the folder doesn’t show a problem and when I do the “service nginx reload/restart” it’s everything ok. Please help!

drwxr-xr-x  5 root root  4096 May  3 00:37 .
drwxr-xr-x  7 root root  4096 May  2 21:06 ..
-rw-r--r--  1 root root  2684 Mar 13 04:57 error_log
-rw-r--r--  1 root root   420 May  3 00:37 index.php
-rw-r--r--  1 root root 19935 Mar  4 18:22 license.txt
-rw-r--r--  1 root root  7425 Mar 13 02:56 readme.html
-rw-r--r--  1 root root  6919 Mar  4 18:22 wp-activate.php
drwxr-xr-x  9 root root  4096 Mar  4 18:22 wp-admin
-rw-r--r--  1 root root   369 Mar  4 18:22 wp-blog-header.php
-rw-r--r--  1 root root  2283 Mar  4 18:22 wp-comments-post.php
-rw-r--r--  1 root root  2898 Mar  4 18:22 wp-config-sample.php
-rw-r--r--  1 root root  2848 Oct 18  2018 wp-config.php
drwxr-xr-x  8 root root  4096 Apr 29 17:59 wp-content
-rw-r--r--  1 root root  3847 Mar  4 18:22 wp-cron.php
drwxr-xr-x 19 root root 12288 Mar  4 18:22 wp-includes
-rw-r--r--  1 root root  2502 Mar  4 18:22 wp-links-opml.php
-rw-r--r--  1 root root  3306 Mar  4 18:22 wp-load.php
-rw-r--r--  1 root root 38883 Mar  4 18:22 wp-login.php
-rw-r--r--  1 root root  8403 Mar  4 18:22 wp-mail.php
-rw-r--r--  1 root root 17947 Mar  4 18:22 wp-settings.php
-rw-r--r--  1 root root 31085 Mar  4 18:22 wp-signup.php
-rw-r--r--  1 root root  4764 Mar  4 18:22 wp-trackback.php
-rw-r--r--  1 root root  3068 Mar  4 18:22 xmlrpc.php

My Server Block (Has a symbolic link in sites-enabled folder)

server {
    listen 80;
    listen [::]:80;

    root /var/www/bnnddr.com;
    index index.php index.html index.htm;

    server_name with WWW and without just in spam case;

    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

And my Nginx Config:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##


        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}
1 Answer

Hello,

This looks like a permissions issue, as your files are currently owned by the root user. What you need to do is to change the owner and the group of your files to the Niginx user.

To do that you could run the following command:

chown -R www-data:www-data /var/www/bnnddr.com

This would change the owner and the group of all files and folders inside the /var/www/bnnddr.com to the www-data user which is the suer that your Nginx service is set to run as.

Hope that this helps!
Regards,
Bobby

Have another answer? Share your knowledge.