Adjusting NGINX for Visible Directories or Files
11 Dec 2015Before we begin
If you want to learn how to set up an NGINX server using your Raspberry Pi, here is a great post by Shane Pfaffly.
Create the directory
From the command line, navigate to your /var/www/ directory. Then create a new directory and name it whatever you desire.
Observe the current permissions
Use the following command to view the current permissions of the files and directories in /var/www/
You’ll see that some files and folders have root permission and some have NGINX permission. We want our newly created directory to have NGINX permission, that way NGINX can display it on your webserver.
Changing directory (or file) permissions
We’ll use the following command and flags to add the directory (or file) to the NGINX permission group.
Modify NGINX config file
Navigate to /etc/nginx/ and open the nginx.config file
Once you have the file open in Nano (or your preferred editor), locate ‘location /’ code block. Should look something like this..
We’ll want add ‘autoindex on;’ to a new line in the code block. In result, it should look like this..
Save and exit.
Restart and test
Now we need to restart our NGINX server to make sure the newly modified config file gets loaded.
Once the server comes back up, try opening that directory in the browser. You may want to add a couple of test files to your new directory, so you can make sure they show up.