19 April 2017

Raspberry Pi: Developing a web server using LAMP (Apache, MySql, PHP )

Raspberry Pi
Purpose
To develop a web server on a raspberry pi that can communicate with another device.

Steps to Follow

Step 1:
Update your raspberry pi.
sudo apt-get update

Step 2:
Installation of the apache web server.
sudo apt-get install apache2-y

Step 3:
To test web server is working properly on localhost find ipv4 address using the following
command
ifconfig
now in my case, ipv4 is 192.168.0.4
Go to a web browser and type http://IP-address
http://192.168.0.4

Step 4:
cd /var/www/HTML
Change owner of file index.html
sudo chown pi: index.html

Step 5:
Install PHP on a pi.
sudo apt-get install php5 libapache2-mod-php5 -y
To test PHP is working properly we will run basic home pf=gr code type following code:
sudo nano index.php
<?php phpinfo(); >?
sudo mv index.htm index1.html
To restart service type following:
sudo /etc/init.d/apache2 relaod
sudo /etc/init.d/apache2 restart
Run code on web browser.
http://192.168.0.4

Step 6:
Install MySQL for creating a database
sudo apt-get install MySQL-server php5-MySQL -y
After successful installation pop up will come to give the password as "root"

Step 7:
Starting MySql
MySQL -u root -p

1. Creating Database
create database Temp;

2. To see database
show databases;

3. selecting Temp database
use Temp;