You are on page 1of 4

EC2 EBS RDS S3Installing WordPress on AWS October 2012 What is Covered Slide Topic 3 Architecture Overview 4 Signup

for AWS 5-13 Part 1: Create an EC2 Instance 14-16 Part 2: Configure your EC2 Instance 17-27 Part 3: Create an RDS Instance 28-33 Part 4: Install WordPress 34-37 Part 5: Configure S3 38-51 Part 6: Install Git 52 Done. The AWSUsers infrastructure for this tutorial Internet Elastic Compute Cloud (EC2) Elastic Block RDS Simple Storage Store (EBS) MySQL Service (S3) Create your free account on AWS - http://aws.amazon.com/free/ Part One:Create an EC2 instanceIn AWS-speak creating a new virtual server is called aninstance. Spinning up an EC2 instance is a phraseyou will hear quite often which just refers to starting anew EC2 instance.EBS refers to the hard drive that is attached to theEC2 instance. Its where all the system files will reside. Step 1: From the AWS Management Console click on the EC2 tab Step 2: Click on Launch Instance and select Quick Launch Wizard (Enter the Instance name, create a new key and select the Amazon Linux AMI) Step 3: Select Amazon Linux AMI(Under Instance details make sure t1.micro is selected its part of the free trial, then select Launch) Step 4: Your instance is being created Step 5: Add rules to the Default Security Group to allow inbound access to EC2 (port 2021 = ftp, port 22 = ssh and port 80 = http) Step 6: Assign an IP address by selecting Elastic IPs Step 7: Right click on the IP address and select Associate. Assign it to your new instance. Step 8: Select your new Instance and right click on it (this contains some very useful information you might need later on) Part Two:Configure your EC2 instanceNow that the EC2 instance has been created its time toinstall the LAMP (Linux, Apache, MySQL and PHP) stackwhich well need before you can install WordPress. TheLinux kernel was preinstalled when the EC2 instance wascreated. Apache and PHP will be installed in this section.MySQL will be installed in the next section. Step 1: Connect to the EC2 instanceThere are two ways you can connect to EC2, one is to right click on the EC2 instancename and launch a Java SSH client. The other way is to use a command line SSH clientsuch as Terminal.app on the Mac. This tutorial will use Terminal. Step 2: Install Apache and PHPFrom Terminal go to the directory that contains <filename>.pem (the file contains your credentials toaccess the EC2 instance.)Change the permission of the file:chmod 400 [filename].pemConnect to your EC2 instance:ssh i [filename].pem ec2-user@[Elastic IP]Switch to superuser:sudo suInstall any new updates:sudo yum updateTo install Apache:yum install httpdStart service:service httpd startStart service automatically:chkconfig httpd onInstall PHP:yum install php phpmysqlRestart Apache web service daemon:service httpd restart Part Three:Create an RDS MySQL instance Step 1: Click on the RDS tab and select Launch DB Instance Step 2: Select MySQL Community Edition Step 3: Select db.t1.small, no for Multi-AZ(db.t1.micro is part of the Free Trial. Remember the Master User Name and User Password for WordPress) Step 4: Enter a Database Name (Remember the Database Name for WordPress)

Step 5: Select the defaults Step 6: Select Launch DB Instance Step 7: The database may take 5 minutes to create Step 8: Click on DB Security Groups and select default Step 9: Click on Select and pick the EC2 Security Group Step 10: Click on your database and review the information (Remember the Endpoint for WordPress) Part Four:Install WordPressWordPress will be installed at the root of your EC2Instance. Step 1: Download WordPressFrom Terminal go to the directory that contains <filename>.pem (the file contains your credentials toaccess the EC2 instance.)Change the permission of the file:chmod 400 [filename].pemConnect to your EC2 instance:ssh i [filename].pem ec2-user@[Elastic IP]Switch to superuser:sudo suChange to the root directory:cd /var/wwwDownload the latest WordPress package:wget http://wordpress.org/latest.tar.gzExtract WordPress:tar -xzvf latest.tar.gzMove WordPress to the html folder:rmdir htmlmv wordpress htmlDelete the WordPress tar file:rm latest.tar.gzChange permissions on the directory:cd /var/www/chmod o+w htmlcd /var/www/htmlsudo chown ec2-user . Step 2: Point your browser to the Elastic IP address and create the config file Step 3: Enter the configuration details and submit RDSEndpoint Step 4: Finish the installation of WordPress Step 4: Goto your Elastic IP address and visit your new blog Part Five:Configure S3S3 will be used to serve up media images (jpg, png,etc...) on the WordPress blog. S3 uses the termbucket, think of it as a container for your files. Thebucket name has to be unique across the entire S3platform. Step 1: Click on the S3 tab and select Create Bucket Step 2: Enter a bucket name Step 3: Click on Upload and upload an image (Use the S3 link when creating a blog post in WordPress) Part Six: SourceTree BeanstalkInstall GitGit is a powerful distributed version control system. Forthis tutorial well be using Git on the EC2 instance,SourceTree an open source Git Mac client and Beanstalk*a service to manage and deploy code. Beanstalk has afree trial plan.* Beanstalk should not be confused with Elastic Beanstalk which is an AWS offering to manage your application. Architecture of Git User X EC2(running Git and Staging Server SourceTree) User Y EC2(running Git and Production Server SourceTree) Users Beanstalk AWS Step 1: Install Git on your local computer1. Goto http://git-scm.com/downloads/ and download the latest version of Git. Double click on theinstaller and follow the directions.2. Download SourceTree an open source Git client from http://www.sourcetreeapp.com and follow theinstructions to install and configure it.3. Open a terminal windowGoto the hidden SSH directory in your home directory:cd ~/.sshGenerate a key (dont enter any passphrase):ssh-keygen -t rsaCopy the generated key to the clipboard (needed for Beanstalk):cat ~/.ssh/id_rsa.pub | pbcopy Step 2: Setup Beanstalk1. Goto http://beanstalkapp.com and setup an account (its free for one user).2. Add your computers SSH key to the account by going to:https://<youraccount>.beanstalkapp.com/public_keys3. Click on Add Public Key 4. Add your SSH key which is in the clipboard ( +P)

Setup Beanstalk (cont.)5. Add a repository by going to https://<youraccount>.beanstalkapp.com/repositories and click onCreate a repository Setup Beanstalk (cont.)6. Give it a name and select Git for type and click Next Step Setup Beanstalk (cont.)7. Click on Set Permissions Setup Beanstalk (cont.)8. Copy the Git URL Setup Beanstalk (cont.)8. Launch SourceTree and click on the icon with the database and plus symbol and add the Gitinformation from Beanstalk. You have successfully cloned the empty repository on Beanstalk to yourlocal computer. Step 3: Install Git on EC2From Terminal go to the directory that contains <filename>.pem (the file contains your credentials toaccess the EC2 instance.)Change the permission of the file:chmod 400 [filename].pemConnect to your EC2 instance:ssh i [filename].pem ec2-user@[Elastic IP]Switch to superuser:sudo suInstall Git:sudo yum install gitCreate a new directory:mkdir /var/www/ferrariSetup a Git repository:mkdir /var/www/ferraricd /var/www/ferrarigit init --bareCopy the beanstalk_rsa.pub file to EC2 then copy the beanstalk_rsa.pub file to the EC2 authorized keysfile:cat beanstalk_rsa.pub >> ~/.ssh/authorized_keys Step 4: Final setup for BeanstalkIn Beanstalk we will configure the server that will have the code deployed to. From the Repository tabclick on Deployment and select Create Server & Environment Step 4: Final setup for BeanstalkSelect SSH for the server type. Step 4: Final setup for BeanstalkEnter the details of your EC2 instance Step 4: Final setup for BeanstalkClick on Next Step Done. You can now start to push code to your EC2 instance from Beanstalk. Done.Now What?Make things and break things to learn how all the variousservices of AWS work together. Visit AWS for moretutorials at: http://aws.amazon.com/articles/ Created by:Manish JainThe backstory to why this presentation was created canbe found on my blog at: http://celestri.org/ [ v1.2 - October 2012 ] AppendixRandom Slides Instructions to manually edit the WordPress config fileCreate and edit the config file:cd /var/www/htmlmv wp-config-sample.php wp-config.phpvi wp-config.phpQuick VI tutorial Press i for edit mode. Press Esc on your keyboard after your are done editing. Thentype :wq to save the file and quit VI.You will need to edit the following entries in the config file with the values from your RDS MySQLinstance:define(DB_NAME, wordpress);define(DB_USER, root);define(DB_PASSWORD, YOUR_PASSWORD);define(DB_HOST, localhost);Below is a mapping of the WordPress config file and the RDS MySQL instance:DB_NAME = Database NameDB_USER = Master UsernameDB_PASSWORD = Master User PasswordDB_HOST = Endpoint Instructions to install MySQL on an EC2 instanceFrom Terminal go to the directory that contains <filename>.pem (the file contains your credentials toaccess the EC2 instance.)Change the permission of the file:chmod 400 [filename].pemConnect to your EC2 instance:ssh -i [filename].pem ec2-user@[Elastic IP]Switch to superuser:sudo suTo install MySQL:yum install mysql-serverStart MySQL:service mysqld startStart the service automatically:chkconfig mysqld onCreate the wordpress database:mysqladmin uroot create wordpressSecure your database installation:mysql_secure_installation

Use Cyberduck to copy files to EC2Cyberduck is an open source FTP/SFTP client. Enter the details below to configure it. Select SFTP Enter ec2-user Your [filename].pem Enter the following commands to give the group ec2-user privileges to copy files to EC2. The user ec2-user is part of the same group name. sudo chgrp ec2-user /var/www/html sudo chmod 770 /var/www/html

You might also like