Home » Blog » Projects

Category: Projects

How To Install Nginx On A Raspberry Pi Running Jessie

I have installed a web server on my Raspberry Pi before. But when I went to do it this last time I noticed a few things have changed.

This post will walk you through some of the hiccups I had when following the official Raspberry Pi documentation on how to install Nginx on a raspberry pi running Jessie.

Here is the official documentation. I would suggest following along with these steps.

First things first, installing Nginx

It’s pretty straightforward to install Nginx on a Raspberry Pi…simply type in the following command,

sudo apt-get install nginx

The first hiccup I had was apt-get returned an error suggesting I update my package manager.

So I simply typed

sudo apt-get update

After a few minutes, I was able to execute the first command with no problems (you might not have to do this).

To start the Nginx server on your Raspberry Pi simply type

sudo /etc/init.d/nginx start

You can now test that your server is installed by visiting http://localhost/ in your browser.

If you want to just run static HTML files you can stop here.

However, if you want to install PHP which gives you the ability to run a scripting language and write more dynamic websites, you will need to install a few more things.

Installing PHP on a Raspberry Pi webserver

The command you are looking for is…

sudo apt-get install php5-fpm

Time to configure some settings

Navigate to cd /etc/nginx

In this file, I notice some discrepancies. I notice that what I had as a default looked very different then what the documentation we telling me.

I tried a few times to get it to work but kept getting the following error.

Reloading nginx configuration (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

Finally I just copied everything that was “suppose” to be uncommented in and reloaded the file and it worked.

So first things first.

We need to tell the server that we want the index file with the .php extension to take preference over those that are HTML.

Around line 25 you will need to add the index.php to the list so it looks like this

index index.php index.html index.htm;

Now, we need to uncomment some options. This is what I was talking about when I said it looked different. I just copied and replaced the section of options with what the documentation said I should have.

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #       # With php5-cgi alone:
        #       fastcgi_pass;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;

This may not be a best practice but I was fed up with Googling error messages and looking in logs.

Finally we can reload this file

sudo /etc/init.d/nginx reload

Here is where things got fuzzy for me

The documentation tells us to change the index.html file to index.php to test if PHP files are being served correctly by the web server.

To do that we can navigate to the path below…

cd /usr/share/nginx/www/

And then change the file extension

sudo mv index.html index.php

I made a change to the file…went to http://localhost and didn’t see it.

I looked back in my terminal and saw that I didn’t have permissions to write to the /www folder.

I started Googling what I need to do to change the folder permissions but wasn’t sure of the right answer (by the way I am not using root as it’s advised to create a new user in Jessie).

However, I remember from a while ago that you can access the webserver files by going to the following path


When I make a change to this index.php file I see the change on localhost as expected.

I am still looking into this but if someone could share thoughts on what I am missing it would be greatly apprecaited.

Here is my final test showing that PHP is running and the change to the file works.


Raspberry Pi OS For Beginners

Getting a Raspberry Pi up and running is easy. All you need is a Raspberry Pi, a power supply, a keyboard, mouse, monitor, and SD card. The hard part is deciding which operating system to install on your Raspberry Pi to launch your first project.

Luckily there are a lot of choices when selecting a Raspberry Pi operating system. Because Linux is an open source system, all of the Raspberry Pi OS are free.

This is nice because you can try all the flavors without worrying about cost.

So here is a breakdown of Raspberry Pi projects/OS for beginners.

If you don’t know which Pi operating system to download or want to try something else. Check out your options.

Read more

Voice Activated LED Coffee Table Powered By Raspberry Pi

This is cool. We love LED lights here at RaspiBakery, and any project that uses LED lights in a cool way.

We also like DIY projects that merge functionality, technology, and furniture. So today, we want to share with you an awesome project from Mikel Duke who used an Arduino and a Raspberry Pi to make an interactive LED coffee table.

You can check Mikel’s video out here.

Read more

5 Of The Best Raspberry Pi Projects For Young Kids

Here are 5 awesome ideas to teach kids the power of computing and programming with a Raspberry Pi.

Originally the Raspberry Pi foundation created the small $35 computer chip to help teachers and students learn the basics of computers. Since then many adults have embraced the power of the small computer. The ability to run multiple Linux distributions and reliably run applications makes the Raspberry Pi the perfect piece of equipment for young kids to learn computing projects.

This list will break down 5 of the very best Raspberry Pi projects for young kids.

Read more

What To Do With A Raspberry Pi

Want to buy a Raspberry Pi? Not sure what to do with a Raspberry Pi? Here is a guide for beginner for some ideas on a Raspberry Pi project. This post will detail some of the most popular, widely supported raspberry pi projects. Hopefully this post will give you an idea of what and how to set up a Raspberry Pi once you decide to buy one. Check out these popular projects.

Read more

Magic Mirror Raspberry Pi Project

Mirror Mirror On The Wall

The magic mirror raspberry pi project is perfect if you are looking for a project to bring technology and functionality together. Michael Teeeuw at Xonay Labs has created a Magic Mirror Raspberry Pi Project that looks clean and serves a unique purpose. What is most impressive about this project is hiding all of the cords associated with powering and displaying the output of a Pi behind a one way mirror. No doubt making the mirror frame took some skill as well. This post will review his mirror project as well as a new take on the magic mirror, with a free download for a web interface to display on your very own RPI mirror project. Below is Michael’s completed Magic Mirror with the time, weather, and a motivational quote.

Read more