11) Install Apache2 with PHP

<-- Previous    Next –>

Installing the Web Server Apache and then the language PHP should be straight forward.

Log onto your Raspberry Pi using a Terminal and type:

sudo get-apt update

This will update your installation.

Then to install PHP and Apache type in:

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

Note that to restart Apache at any time enter:

sudo service apache2 restart

This will set up a web server at /var/www/html

Now if you go to your browser on your computer and type http://servername/ it should display a start up page.

An extra step is to enable htaccess files.  These are file that you place on your web site and give you the abiltiy to make configuration changes on a directory by directory bases.

To enable htaccess files you must modify the config of Apache:

sudo nano /etc/apache2/apache2.conf

You’ll see a line like the following near <Directory /var/www/html/> for your web folder:

“AllowOverride None” – change this to “AllowOverride ALL”

Then hold the Ctrl+X key, then press Y and press Return.

Now restart Apache with:

sudo service apache2 restart

<-- Previous    Next –>