I’m hoping there would be more people like me who set up LAMP server on AWS Linux EC2 Instance. I’ve done it multiple times and realized that it’s time to write a script to automate the setup.
I’ve shared the script on GitHub. Detailed below are the steps to be followed.
How it works
So I’ve created a script which is supposed to be run in three parts. The reason for three parts is that
- you need to logout from server to access the changes that have been made by the script. (Maybe there’s a better way and maybe I’ll come across it later).
- Some people might not want to install phpMyAdmin so they can skip the third script.
The script is broken down in three parts. And each is supposed to be executed one after the other. Don’t forget to logout and login after each part.
Step 0: Clone the repository
Use git clone to clone the repository and set necessary permissions.
git clone https://github.com/stinct9/aws-lamp.git
The script needs to be made executable, so run
chmod +x 1-aws.sh 2-aws.sh 3-aws.sh
Step 1: Install php & MySQL
Next step installs php, Mysql and other dependencies.
Once the script has completed running, please exit and login to the server again.
Step 2: Setting Permissions
Step 3: Installing phpMyAdmin
You may skip this step if you don’t want to install phpMyAdmin
Next install phpMyAdmin with the step 3 script. Here first it is very important to change the IP address field in the script
sudo nano 3-aws.sh
and modify the below line with your IP address. Replace your-ipaddress with your actual IP address. It would be something like 184.108.40.206. You can check your real ip address from whatismyip.com
sudo sed -i -e 's/127.0.0.1/your-ipaddress/g' /etc/httpd/conf.d/phpMyAdmin.conf
Next run the script
This will install phpMyAdmin and accessible only from the
your-ipaddress you defined earlier.
Access phpMyAdmin from any IP
If you would like to allow access to phpMyadmin from any IP Address (although it is insecure, and not recommended), you can do it by editing the
phpMyAdmin.conf file located in
The above will setup a bare LAMP server on AWS EC2. Comments welcome.