Posted in Amazon Web Services, LAMP

Setting LAMP stack in Ubuntu 16.04 using AWS EC2

Set up your Ubuntu EC2 instance with LAMP stack – Linux, Apache, MySQL, PHP. I have used Ubuntu 16.04 machine. To know how to set up an instance in AWS, check this post.

Step 1: Installing Apache 2.4

$ sudo apt-get install apache2

Step 2: Installing MySQL
You will be prompted for username and password for database.

$ sudo apt-get install mysql-server

Step 3: Installing PHP
You need to include some helper packages for mod, mysql and mcrypt.

$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

Step 4: Modify permission (optional)
By default, /var/www/html directory will not be available to write unless you are a super user. So grant full permission for html directory.

$ sudo chmod 777 /var/www/html/

Step 5: Test installation

Create a file (say index.php) in /var/www/html/ and paste the following:

<?php
phpinfo();

Now, open your instance endpoint in your browser and access the file you created. In my case,

http://<my-ip>/index.php

If you see PHP information page, you are all set!

Advertisements

One thought on “Setting LAMP stack in Ubuntu 16.04 using AWS EC2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s