404 Not Found nginx/1.10.0 (Ubuntu)

Hi guys,

I install wordpress on Lemp on 16.04 ( this was installed using the via DO droplet) following this tutorial everything went well, but when I changed the permalinks to post-name since then apart from the home page anything else returns with this error ( 404 Not Found nginx/1.10.0 (Ubuntu) ) now I did of course followed the instruction for making changes in the /etc/nginx/sites-available/default take a look at my file below

GNU nano 2.5.3 File: /etc/nginx/sites-available/default

Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

Default server configuration

server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: # # Read up on ssl_ciphers to ensure a secure configuration. # See: # # Self signed certs generated by the ssl-cert package # Don’t use them in a production server! # # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    http {
index index.html index.htm index.php index.nginx-debian.html;

    server_name _;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            #try_files $uri $uri/ =404;
             try_files $uri $uri/ /index.php$is_args$args;

    # pass the PHP scripts to FastCGI server listening on
    #location ~ \.php$ {
    #       include snippets/fastcgi-php.conf;
    #       # With php7.0-cgi alone:
    #       fastcgi_pass;
    #       # With php7.0-fpm:
    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #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;


I didn’t follow the instructions for installing ssl because this is test and I m did made another user with sudo privileges but there was nothing in the tutorial about switching to non root user at any point, so I continued using the root user for all the process. I m completely new to this so can someone please help me with this. Also I have a sub domain that has it’s own WordPress installation but would be placed in the same dictionary and I m also planing on installing Vanilla forum as a subdomain or For now I m just doing this on test environment using DO droplet and the ip address as the domain. Thanks in advance for any help.

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.

Accepted Answer

Make sure you have your WordPress site stored in /var/www/html and set correct permissions on /var/www/html and it’s content. To check, the following simple ls command will do the job:

  1. ls -ld /var/www/html

Also, for content:

  1. ls -l /var/www/html

Recommended permissions are sammy:www-data, where sammy is your non-root user. If it’s not like that, you can set them by running:

  1. sudo chown -R sammy:www-data /var/www/html

Also, make sure you have WordPress unpacked in /var/www/html and not in /var/www/html/wordpress or anything similar. You can also post result of ls -l /var/www/html, so we’re sure you did it right.

If nothing helps, best bet are to check logs. Check for latest entries in /var/log/nginx/error.log and /var/log/nginx/access.log. The first one is the most relevant and will probably tell you the reason of error. If you’re not sure how to debug it, you can post it here (make sure to redact any sensible information).

As of forum and another WP site. You can’t do it like you explained. First, you can’t have two WP sites in one directory. The best way would be to create appropriate directories in /var/www for each site. For example in /var/www/ store WordPress site running on main domain -, and in /var/www/ store site running on the subdomain. As for forum, I wouldn’t recommend using as it can break WordPress permalinks. Do it with subdomains, on the same way I explained above - create directory for it, e.g. /var/www/ and store it there. All this would require you to create appropriate Nginx server blocks and the How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04 will show you how to do it.

Thanks to all, adding this > try_files $uri $uri/ /index.php?$args; to sites available worked for me.

I had the same issue after I installed the nginx on my server. The error was caused by some bad statements in my conf file. I just had to add this to the conf file:

include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_index index.php;

I used this tutorial, check maybe it will help.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel