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

http://pws01/

And the default Apache2 page will show (See picture)

Full documentation is available at Apache.org

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

[Apache_folder]
   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

<?php
 phpinfo();
?>

and place it in the RPi folder 

var/www/html

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

http://pws01/phpinfo.php

and the information about PHP and the server will show.

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


No comments:

Post a Comment