Skip to content

Instantly share code, notes, and snippets.

@christiearcus
Last active May 15, 2017 09:57
Show Gist options
  • Save christiearcus/b0cfba4997ae09de14e7c9778f1e3921 to your computer and use it in GitHub Desktop.
Save christiearcus/b0cfba4997ae09de14e7c9778f1e3921 to your computer and use it in GitHub Desktop.
Ops weekly hangs 01
#!/bin/bash
wget https://wordpress.org/latest.tar.gz
yum install mysql-server mysql php php-mysql mysql-devel mysql-libs httpd -y
tar xvfz latest.tar.gz -C /var/www/html/
service httpd start
service mysqld start
chown -R apache /var/www/html

Agenda

1. manually create an EC2 instance & ssh in to it

  • Go to AWS console, and in instances create a new instance with an amazon linux AMI and all the default settings.
  • Download the key pair generated and put in .ssh folder
  • ssh in to the created instance:

ssh ec2-user@[instance public IP address] -i ~/.ssh/[your-key-name]

Run wordpress on it

wget https://wordpress.org/latest.tar.gz- download wordpress sudo yum install mysql-server mysql php php-mysql mysql-devel mysql-libs httpd - download dependencies sudo tar xvfz latest.tar.gz -C /var/www/html/ - unzip in to this path sudo chown - can't remember this command to change owner to apache? sudo service httpd start - start web server (apache) sudo service mysqld start - start database

Then you should be able to see it live on public IP address [IP]/wordpress

Create a launch config to automate this

  • Create a launch config in AWS console
  • Use amazon linux AMI
  • Give it a name that you can find in the console, and in the user data section put your instructions (like above). Don't need to use sudo, as it runs these commands as the root user. For now, assign a public IP to every instance.
  • In security groups, keep SSH and create an HTTP type with port 80.
  • Assign your key pair to it.

Create an ASG

  • Select your launch config
  • Name and add your subnets
  • Just use defaults for the rest and confirm

Now you should be able to see your instances being spun up! You can ssh in to any of them to check that all of the stuff was installed properly.

  • cd in to /var/log
  • cat cloud-init-output.log to view all of the output of your installed things. If there are issues you will have to create a copy of your launch config and assign your ASG to it. You can view instances under that ASG and terminate the old ones.
@christiearcus
Copy link
Author

Put .pem in to .ssh folder & make sure to chmod 600 it (otherwise you won't be able to ssh in to it).

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