How to Install Lamp Server on Debian Wheezy in Amazon EC2 Instance

aws-lamp-logo

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 where as 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. Every virtual host needs its own configuration file in the /etc/apache2/sites-available/ directory. Create the file for example.com, called /etc/apache2/sites-available/example.com.conf, with the following content. Make sure to replace example.com with your own domain name.

# vim /etc/apache2/sites-available/example.com.conf

Lamp apache2 conf file pic

Step 4. Restart apache2 service.

# service apache2 restart

Step 5. Now direct your browser to http://ip or www.example.com and you should see the Apache2  page like this.

Lamp Apache2 webpage

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

# apt-get install mysql-server -y

Step 8. Specify New password for Mysql root user.

Lamp mysql new password pic

Note: Confirm Password for Mysql root user.

Lamp mysql confirm password pic

Step 9. Install Php5 by running bellow command from your terminal.

# apt-get install php5 php-pear php5-curl php5-gd php5-mysql -y

Step 10. The document root of the webserver is /var/www/. Now We will create  PHP file (info.php) in  /var/www/ 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.

# vim /var/www/info.php

<?php
phpinfo();
?>


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

http:/ip/info.php
or
http:example.com/info.php

Lamp php webpage pic