Visit my website New

Sunday, 20 December 2015

Raspberry Pi Apache Server Led ON OFF

Install Apache

Apache is a Popular web server, it can serve HTML files over HTTP, and with additional modules can serve dynamic webpages using scripting language such as PHP. It can be installed on Raspberry Pi.

First install apache2 package

sudo apt-get install apache2 -y

Test the web server 

By default, Apache puts a test HTML file in the web folder. The default webpage is served when you browse to http://localhost/ on the pi itself or (Your Pi's ip address).

raspberry pi default apache page

This means you have Apache working!

The default webpage is just html file on the system. It is located at /var/www/index.html

Navigate to this directory in the terminal and have a look at what's inside
cd  /var/www/ 

ls -al

This shows the content of the file along with user which owns the file, file size and last modification date & time.

Additional -Install PHP

PHP helps to execute the python file dynamically on the webpage. To install PHP on Raspberry Pi,
sudo apt-get install php5 libapache5-mod-php5

Creating a PHP file to execute the python file on the webpage:

Move to the directory /var/www 

Create a file named index.php and place the following codes.

Download the index.php file
The webpage could look like below

The python file for each button should be like this
LED ON (      LED OFF (