Setting up Apache and PHP in Raspberry Pi 2

Apache is a very popular Web Server Web Application where you can install on Raspberry Pi 2 which provides you various web pages for your requirement.Apache can provide you various HTML Pages along with other Powerful  Scripting Languages like PHP.

Let us  see the installation go Apache in Raspberry Pi 2:

sudo apt-get update

sudo apt-get install apache2 -y

That’s it! Installation Done Successfully.

Test the working of Apache(Web Server):

Open you Raspberry Pi browser or any other System browser which is available in the same network and type Raspberry Pi IP address you should the following message which means your Apache is working fine.

 

apache-it-works

The default webpage is located in the following path

/var/www/index.html

You can create you own html page and replace it here!!

PHP Installation:

To process PHP files in apache server we need to install PHP5 and PHP5 module for apache.

Type the following commands to install PHP5 and its Module.

sudo aptget install php5 libapache2modphp5 y

Now remove the index.html file from Apache server replace it with index.php and write some php to content to check the working.I am writing a simple hello world and displaying date and time.

<?php echo "hello world";

<?php echo date('Y-m-d H:i:s');

Now reload your page in browser ,you should see the changes 🙂

For more queries:

info@adhiratech.com

080-23240875

Posted in Dev Boards, development boards, image processing, Raspberry P and tagged , , .