James Wood Creative

Install Nginx on a Raspberry Pi

17 January, 2015

Once Raspbian is up and running, maybe it’s time to install a web server.

First, install nginx: sudo apt-get install nginx

Then open the nginx config file using Nano: sudo nano /etc/nginx/sites-available/default

Find the line that says: root /usr/share/nginx/www; Change it to root /var/www/sitename; (with your chosen site name!) Press ctrl+o, enter to save (“o” stands for “write out”, then ctrl+x to exit from Nano.

Make a new folder for your website to live in: sudo mkdir /var/www/sitename (with the same site name you chose earlier)

Change the ownership of your folder so that both the Pi user and the www-data group (nginx!) can access it:

sudo chown -R pi:www-data /var/www
sudo chmod -R 0755 /var/www

Then all that’s left is to start nginx. Starting it as a service will allow it to run in the background: sudo service nginx start

Visit your Pi’s IP address from another computer to see if it worked. If you don’t know what the address is, type ifconfig to see something like this:

eth0	Link encap:Ethernet  HWaddr XX:XX:09:XX:XX:XX
	inet addr: