Raspberry Pi Webserver

One of the reasons that I purchased a Raspberry Pi was so that I can do local website development. Of course, I could have easily set this all up with Windows, but my desktop is already cluttered enough. And with a Raspberry Pi Webserver, I can set up scipts to run independently of my desktop. Here’s how to setup a Raspberry Pi Webserver

What You Will Need:

  • Raspberry Pi

Install Apache

So for right now, we are not going to get fancy with a Node JS server or anything like that. We are going to setup a simple apache server to serve html files. Open up terminal and type in the following:

sudo atp-get update

sudo apt-get install apache2 -y

This will install the apache server. To test that it works, navigate to http://localhost on the raspberry pi or to the Pi’s iP address (192.xxx.xxx) on any other device. You should be greeted by the following welcome page. Remember that the default location of your website is the var/www/html directory.

Install PHP

Unless you’re building a truly static website, you will also need the assistant of PHP to perform some server-side tasks. To install php type the following in terminal:

sudo apt-get install php5 libapache2-mod-php5 -y

You can through a php file in the website directory to test that it is working. And that is it. You now have a webserver running on the raspberry pi.