ChildOfCode


Code, Maker, Robotic, Open Source. Knowledge Bases


RaspberryPi 2 Setup LAMP

The First thing I want to try in Raspberry Pi 2 is setup a LAMP server .
currently have one Project is using LAMP to run. so i can try this out on the RPI 2.
Last time i have try Install LAMP in Raspberry Pi 2 in my A+ but fail in the MYSQL section .

Before start

sudo raspi-config  

change the RaspberryPi Passwrod and Expand Filesystem .

1)First let update the Pi

sudo apt-get update  
sudo apt-get dist-upgrade  
sudo apt-get install raspberrypi-ui-mods  

2) Install Apache Server 2 and PHP5

sudo su  
apt-get install apache2  
apt-get install php5  
apt-get install libapache2-mod-php5  
/etc/init.d/apache2 restart

Acess the RaspberryPi 2 apache in other Computer.
*Note I have edit the HTML you may only see thw word "It words!" only

3)Write some PHP code to test PHP is sucuess install.

cd /var/www/  

Create a PHP Files

nano testrun.php  

Code something to test the PHP
Normally people will use phpinfo() to test the server
but here may have some little secure issue if someone try to hack you server and see this he will get some information for here.

Option1

<?php phpinfo() ?>  

Other way to check the PHP
Option2

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

If you are using Option1 phpinfo remember delete after testing.

4) Install MYSQL Server

apt-get install mysql-server  
apt-get install php5-mysql  
apt-get install libapache2-mod-auth-mysql

5)Install phpMyAdmin

apt-get install phpmyadmin  

6)Setup phpMyAdmin in Apache2

nano /etc/apache2/apache2.conf  

add below code inside the apache2.conf

Include /etc/phpmyadmin/apache.conf  

Restart the Apache2

/etc/init.d/apache2 restart

Done! Enjoy the LAMP in RaspberryPi !