Monday, 27 February 2017

RPi install Apache/PHP WEB-server

As a part of one of my project, the ultimate Weather site ?? Weather34, I needed a WEB-host with PHP.

I started up with a fresh Raspbian Lite SD Card with Samba installed.

Log on, with ssh, to the RaspberryPi(RPi), with in this case hostname "pws01", and start to install the Apache server with

$ sudo apt-get install apache2

Check that the Apache server works with a WEB-browser and the URL


And the default Apache2 page will show (See picture)

Full documentation is available at

Modify folder owner/permission

$ sudo chown pi:pi /var/www/html

Install PHP

$ sudo aptitude install php5 libapache2-mod-php5

Check the install

$ php -v 

And something like this will show

pi@pws01:~ $ php -v
PHP 5.6.29-0+deb8u1 (cli) (built: Dec 17 2016 06:04:43) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Create a Samba share of the default Apache document root which will make it very simple to add and edit files on the RPi from Your Mac or PC.

$ sudo nano /etc/samba/smb.conf

add this at the end of the file

   comment = Apache folders   
   read only = no
   locking = no
   path = /var/www/html/    
   guest ok = no

and restart the Samba server

$ sudo /etc/init.d/samba restart

Create a file "phpinfo.php" with following text


and place it in the RPi folder 


In Your browser use the URL below to check that everything works


and the information about PHP and the server will show.

If there is a need for restarting the Apache server use 

$ sudo service apache2 restart

Now You can move on to install the Weather34 project or use the WEB-server to something else.

No comments:

Post a Comment