Skip to content

Instantly share code, notes, and snippets.

@keithweaver
Created March 20, 2017 22:48
Show Gist options
  • Save keithweaver/546e70bd0c88f4bef49b9051b3ba47bb to your computer and use it in GitHub Desktop.
Save keithweaver/546e70bd0c88f4bef49b9051b3ba47bb to your computer and use it in GitHub Desktop.
Setting up a LAMP stack on Amazon Web Services (AWS) EC2

Setting Up EC2

  1. Sign into AWS
  2. Open EC2
  3. Click Instances on Left Side
  4. Click "Launch Instance"
  5. Select "Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type"
  6. Select Free Tier
  7. Click review and launch
  8. Press Launch
  9. Create Pair
  10. Download Pair
  11. Launch Instance
  12. Open list of Instances
  13. Swap in your file name: chmod 400 ServerPair.pem
  14. Swap in your file name and ip address: ssh -i "ServerPair.pem" [email protected]
  15. Update your instance sudo yum update -y
  16. Install Apache Web Server, MySQL, PHP sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
  17. Start the Apache Web Server sudo service httpd start
  18. Make it so Apache Web Server runs on server boot: sudo chkconfig httpd on
  19. Verify it with: chkconfig --list httpd and httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  20. Go to your Public DNS or IPv4 Public IP: Example: ec2-54-152-134-146.compute-1.amazonaws.com
  21. Create a new user group sudo groupadd www
  22. Add our EC2 User to this group sudo usermod -a -G www ec2-user
  23. Leave the current session exit
  24. Sign back in. Swap in your file name and ip address: ssh -i "ServerPair.pem" [email protected]
  25. Verify www exists by running: groups
  26. Give www permission on server files /var/www with sudo chown -R root:www /var/www
  27. Change file permissions: sudo chmod 2775 /var/www and find /var/www -type d -exec sudo chmod 2775 {} \;
  28. Add a index.html in var/www/html so touch /var/www/html/index.html and vi /var/www/html/index.html then add content.
  29. Go back to Instances (like the list)
  30. Right click on your new instance, select Networking, then Change Security Group
  31. Take note of which one is selected
  32. Open Security Groups on the left side: https://console.aws.amazon.com/ec2/
  33. Edit the Inbound rules for that security group already assigned.
  34. Add Rule and set the type to be HTTP
  35. Files sit in ls -l /var/www
  36. Go to your IPv4 and you should see Hello World!
Copy link

ghost commented May 6, 2018

This is great!

I'm wondering if you wanted to use NGINX behind Apache, where would that setup go best in this list.

@ssaltman
Copy link

ssaltman commented May 19, 2018

I used the Amazon Linux 2 LTS Candidate 2 AMI ami-afd15ed0 and I had to change line #16 of your GIST to be sudo yum install -y httpd.x86_64 Php.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-mysqlnd.x86_64 to get the correct installation packages.

Just wondering if I got that right? Note, I didn't continue with this because the output on ssh didn't match your video...went back to Linux 1 AMI. But still wondering if that's the correct update list.

@vandanavcode
Copy link

Hi, i'm new and i want to host cms web app developed in codeiginator. can you please tell me how to host in aws in step bye step procedure.
Thank you

@Rameswari-Jena
Copy link

Rameswari-Jena commented Aug 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment