Lighttpd web server has been chosen for this project, you can use Apache or anything else you like that supports PHP, I found others a little heavy for this.
As normal, ensure your system is up to date and cleanup any archived download packages using the below code;
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get clean
Install Lighttpd
After running the update and cleanup from above, go for launch!
sudo apt-get install lighttpd
Reboot the system to get all the services up and running together.
sudo reboot now
www-data Permissions
I think there is a miss conception concerning the folder permissions for this section, most instructions that I have come across say to add the pi user to the www-data group to allow modify access the the files.
I think this is wrong as the Lighttp daemon runs in its own service with access to no writable files/folders, apart from \tmp. This is great for security, but if you add the pi user to this group, you are then allowing write access to your web folder.
Instead, the pi user takes ownership of the www-data folder and provides Lighttp with read and modify access to only the files it needs.
sudo chown -R pi:www-data /var/www
sudo chmod u+rxw,g+rx-w,o-rwx /var/www
sudo chmod g+s /var/www
chmod documentation: https://ss64.com/bash/chmod.html
Install PHP
Install php7.0 including it’s dependencies
sudo apt-get install php7.0-common php7.0-cgi php7.0
To enable Lighttp with PHP FastCGI, use the below code;
sudo lighty-enable-mod fastcgi-php
Reload the service;
sudo service lighttpd force-reload
Testing time
From another device, using an internet browser, navigate to your Raspberry Pi’s address i.e. http://raspberrypi or the hostname updated in the install section.
If no page loads, check the logs Lighttp logs located at /var/log/lighttpd/error.log