How to Install Apache, Mysql, PHP ( LAMP ) on Debian 8

debian-lamp

LAMP is a complete package to run any web application on a server. LAMP signifies the Linux, Apache, MySQL and Php. Apache is used as the web server for hosting of an application whereas MySQL is used as systematic data storage of application & Php is popular server-side scripting language which is used for web development as well bridging the gap between application and the database.


Step 1.
Open your EC2 Terminal and update your Packages.

# apt-get update

Step 2. Install apache2 webserver.

# apt-get install apache2 -y

Step 3. Now direct your browser to http://ip  and you should see the Apache2  page like this.

apache2-main-page-pic

Step 4. Install mysql-server in your Machine by running bellow command from your terminal.

# apt-get install mysql-server -y

Step 5. Specify New password for Mysql root user.

mysql-passwd-pic

Note: Confirm Password for Mysql root user.

mysql-passwd-confirm-pic

Step 6.  Execute below lines to get PHP Repository in your apt source file.

# echo deb http://packages.dotdeb.org jessie all >> /etc/apt/sources.list
# wget http://www.dotdeb.org/dotdeb.gpg
# apt-key add dotdeb.gpg

Step 7. Update Packages.

# apt-get update

Step 8. Install Php7 by running bellow command from your terminal.

# apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring  -y

Step 9. The document root of the webserver is /var/www/html. Now we will create  PHP file (info.php) in  /var/www/html/ directory and call it through a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

# vi /var/www/html/info.php

<?php
phpinfo();
?>

Step 10. Finish up by visiting your php info page.The page should look like this.

http://ip/info.php

php-page-pic