Setting Linux, Apache, MySQL, PHP stack in Ubuntu 16.04 using AWS EC2
Set up Ubuntu EC2 Instance with LAMP Stack — Linux, Apache, MySQL, PHP.
To know on how to create EC2 Instance with Amazon Web Services, check out 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!