Question

Stuck on nginx multisite Wordpress (LEMP)

Hi! I have read a lot about this, but I can’t figure it out why is not working for me. The idea is the following: I want to host several websites on a single droplet. The scheme is like this:

wargostudio.com -> stuck oncativosa.wargostudio.com -> working fine jalisco.wargostudio.com -> working fine

example2.com sub1.example2.com … etc

when I go to wargostudio.com, I get a blank page. In the error log, the server is trying to access /usr/share/nginx/html/ but** I have specified another path.** Whats going on?

Thanks very much, and sorry for the length of the question.

So my first domain is: wargostudio.com and the config file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/wargostudio;

    index index.php index.html index.htm index.nginx-debian.html;

    # include snippets/wp-supercache.conf;

    server_name wargostudio.com www.wargostudio.com;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    location ~ /.well-known {
        allow all; 
    }

}
server {
    # SSL configuration

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    include snippets/ssl-wargostudio.com.conf;
    include snippets/ssl-params.conf;
}

And one subdomain (oncativosa.wargostudo.com) is like this:

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

    root /var/www/oncativosa;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name oncativosa.wargostudio.com;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

And finally jalisco.wargostudio.com

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

        root /var/www/jaliscopaletas;

        index index.php index.html index.htm index.nginx-debian.html;

        include snippets/wp-supercache.conf;

        server_name jalisco.wargostudio.com;

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

        # Caching of media: images, icons, video, audio, HTC
        location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
                expires 2M;
                add_header Cache-Control "public";
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        # CSS and Javascript
        location ~* \.(?:css|js)$ {
                expires 1d;
                add_header Cache-Control "public";
        }


        location ~ /\.ht {
                deny all;
        }
}


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks so much to everyone!!

@francarranza

I’ve actually never seen that error to be honest, though there is one more thing we can try and it doesn’t require too many changes.

Instead of using sockets, we can use TCP.

In each of the ./pool.d files we modified, find the listen = directive. We’ll set PHP-FPM to listen on a specific port instead of using a socket. You’ll increment the port for each site, starting with port 9000.

/etc/php/7.0/fpm/pool.d/wargostudio.conf

listen = 127.0.0.1:9000

/etc/php/7.0/fpm/pool.d/oncativosa.conf

listen = 127.0.0.1:9001

/etc/php/7.0/fpm/pool.d/jaliscopaletas.conf

listen = 127.0.0.1:9002

No other changes should need to be made as long as you’ve made the previous changes, so let’s go ahead and restart PHP-FPM:

service php7.0-fpm restart

Now we need to modify each NGINX server block to match the new TCP connections.

wargostudio

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
    }

oncativosa

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9001;
    }

jaliscopaletas

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9002;
    }

You’d now restart NGINX:

service nginx restart

Now, I can’t tell what’s in snippets/fastcgi-php.conf, so if you can post that to a code block using the </> icon, we can see if there’s anything there that may be causing some issues too.

Hi, thanks for the answer. I’m having now this issue: Connection refused (111), your cache admin is root. It seems to have a problem with the permissions for the new users.