Tuesday, July 28, 2015

Internet of things - Rasberry Pi - Install Lighttpd & PHP

Install Lighttpd & PHP on Rasberry Pi

Lighttpd is a lightweight web server, with all the essential functions of a web server
sudo apt-get update (download package lists from the repositories)
sudo apt-get -y install lighttpd .


Install PHP
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.
sudo apt-get install php5-common php5-cgi php5
sudo lighty-enable-mod fastcgi-php (Enable the Fastcgi module which will handle the PHP pages)
sudo service lighttpd force-reload (restart the Lighttpd service)


Permission
The /var/www is the root directory of the website, it is currently owned by the “root” user. We must ensure the "Pi" user account can write files to /var/www directory.
sudo chown www-data:www-data /var/www
sudo chmod 775 /var/www (permission to write to this directory)
sudo usermod -a -G www-data pi (add the “Pi” user to the “www-data” group)

Reboot the Raspberry Pi, your Raspberry Pi web server is ready.

When the Pi restarts, you need to check that PHP is running. You can do this by creating a web page that includes a call to phpinfo() which will show various settings. Use nano to create a file called phpinfo.php and then connect it though the Pi's web server:

sudo nano /var/www/phpinfo.php
Enter the text as shown here:
  phpinfo();
?>

No comments: