I cannot see files uploaded to ngnix website path

July 4, 2015 1.6k views
LEMP Nginx Ubuntu

I upload my web site via dploy.io, I have provided /usr/share/ngnix/html as the path to upload files. Dploy tells me the file are successfully uploaded, but I cannot see them when I log as root (using putty). Yet, if I do a find / -name 'world.html' -print ubuntu tells me the file is there! yet, no amount of ls -la will show it, and oddly report 20 files while only 5 showing (including . and .. entries). I destroyed and reinstalled the droplet many times trying different variations without success. I am not sure if it's an Ubuntu or an Ngnix issue, or neither. Any help would be greatly appreciated. Thank you.

Here's a paste of session interaction:

root@valcatraz:/usr/share/nginx/html# ls -la
total 20
drwxr-xr-x 2 root root 4096 Jul 4 12:36 .
drwxr-xr-x 3 root root 4096 Mar 24 12:11 ..
-rw-r--r-- 1 root root 537 Mar 4 2014 50x.html
-rw-r--r-- 1 root root 618 Jul 4 12:36 index.html
-rw-r--r-- 1 root root 20 Mar 24 12:12 info.php

root@valcatraz:/usr/share/nginx/html# find / -name 'world.html' -print


4 Answers

Welcome to DigitalOcean

We need to change the root

nano /etc/nginx/sites-available/default

or use your preferred text-editor

Change root to :

root  /usr/share/ngnix/html;

Change location / to :

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


Save and restart nginx

service nginx restart

If it works click that hearth to show me some love :-)

Sadly everything was already like how you suggested, except the "autoindex on;" statement, but adding it hasn't changed a thing.

How is it possible that the shell tells me there is 20 files there and show me only 3? I am no unix guru by any stretch of the imagination, but I have never seen anything like that. How cand "find" report the file, but not "ls"? :(

I just chose a droplet with every installed hoping to just have to put my files, but apparently there are some other steps I need to take, maybe it's a security/user/group/etc thing that I have to set?

  • What do you mean with you can't see them ?

    Can you access the file over the Browser ?

    To list files you just need to do ls.
    ls -la says how many files you have in a Directory including Subdirectories.

Well, if you look at my original post you can see that "ls -la" reports that there are 20 files and shows only 3, with no subdirectory at all (it's out of the box, I haven't installed these files, they were already there).

You can also see that when I ask "find" to search for "world.html" it says it's found in usr/share/ngnix/html, although "ls" tells me otherwise....

And now, without me having done anything since last reply, "ls -la" reports only 12 files (no longer 20) and shows the same 3 that where already there.

Scratching my head...

  • This sounds really weird, I actually don't know what you can do.

    Years of experience and I never saw this or an similar problem.

    How about you create your Droplet your own and follow this Tutorial to install Nginx https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-14-04-lts

    Then you can upload your files to the folder /var/www/html using FileZilla

    Hostname: sftp://Your Droplet IP
    Username: root
    Password: YourRootPassword

    And again you need to use ls to list files.

    An Example:

    ls -la
    total 5

    / has the folder abcd and abcd has 4 files 1+4=5

    The change from 20 to 12 is really weird.

    by Justin Ellingwood
    Nginx is one of the most popular web servers in the world. It is extremely flexible and powerful and can be used to efficiently host sites and applications small or large sites and applications. In this guide we'll cover how to install and set this up on an Ubuntu 14.04 server.

Ok, thanks, will follow your suggestion.

Have another answer? Share your knowledge.