NGINX config for Wordpress in sub-directory, served on root - Ubuntu 18.04

I’ve messed around with these settings for a solid 2 hours now, but just can’t seem to get it right. I want my site to display at, and the wordpress directory is at /var/www/ I was able to install Wordpress correctly, and later the settings under general to tell Wordpress where the directory / site are, but something about my server block is wrong. (403) (works, but should be at (works - though in my attempts, there was a point where this would not work without being followed by index.php) (403)

I followed quite a few guides to get set up (also have cert bot for SSL), but ultimately these two:

The only place I ventured off guide, was to give Wordpress its own directory. I’ve tried to make proper sense of the server block rules, but despite my best attempts, I’m still missing something.

Lastly - what’s the difference between /index.php$is_args$args; and /index.php?$args; ? The 18.04 guide uses the former markup, where as the older 16.04 uses the latter.

server {
        root /var/www/;
        index index.php index.html index.htm index.nginx-debian.html;

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

        #location /wordpress {
        #       index index.php index.html index.htm;
        #       try_files $uri $uri/ /index.php?$args;

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

        location ~ /\.ht {
                deny all;

        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


If your Wordpress installation is at /var/www/ then you need to make sure that your Nginx document root is also set to /var/www/

Another thing that you need to keep in mind is that your Wordpress Site and Home URLs need to be set to rather than

Regards, Bobby