Monday, 29 October 2012

Installing and setting up Apache, PHP

This is what I've done to get Apache & php installed and set up on my RaspberryPi.

Background reading


Things you may want to do before you install

Set a static IP address and Host name

Getting started

First things first update and upgrade the image by running the commands

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

depending on when you last did this and how old your image is this may take 30 minutes or more.

So now on to installing apache

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

You may have noticed a couple of errors when installing, to fix you need to run the following commands
sudo groupadd www-data, then sudo usermod -g www-data www-data.

Now restart the apache web server by running the command sudo service apache2 restart

To enable htaccess files you must modify the config files, like so:

Type sudo nano /etc/apache2/sites-enabled/000-default and hit Return / Enter.
You'll see a line like the following:

"AllowOverride None" - change this to "AllowOverride ALL".
(Note that "AllowOverride None" appears in a couple of places. You want to update the one under <Directory /var/www/>)

To save your changes hold the Ctrl button and press the "x" key, then press "y" when prompted and hit Return / Enter.
Now restart apache with sudo service apache2 restart.

And that should be it :-)

Check Apache

You can check that its all working by opening up a web browser and entering the url: http://raspberrypi/

Alternatively from the pi itself go to http://127.0.0.1 or http://localhost

No comments:

Post a Comment