Thursday, March 16, 2017

How to turn your Raspberry Pi into a Web Server...

Many "first" Raspberry Pi projects are actually overly ambitious and complicated for beginners.  Well, here's one that is quick, easy, and free.  Assuming you've already set up your Raspberry Pi, just follow these steps to turn your Pi into a fully functional Web Server and host your own website.

(You will be entering these commands in the Terminal window.)


1. Install updates.

sudo apt-get update && sudo apt-get upgrade


2.  Install the Apache Web Server and PHP

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


3.  Then restart the server with:

sudo service apache2 restart


That's pretty much it. You can view the default web page by entering your Pi's local IP address in the browser (something like http://192.168.1.7).

Once you set up port forwarding on your router, you can then view your web page with the IP address that the rest of the world will use to reach your site. To determine this, just Google "WhatsMyIP".

In the future, you'll use this as the Pi's directory for your website:  /var/www/html

One final, but very important, thing....  In order to make any changes to your "html" directory, you'll need to change its permissions.  Open the Terminal, navigate to the "www" directory, and enter this command to change the owner from "root" to "pi" (or your username):

sudo chown pi: html


You can check out my Raspberry Pi-powered website at: http://100.1.187.241

If publishing websites was hard, the Internet wouldn't be what it is.


  

0 Comments:

Post a Comment

<< Home