I decided to move my small project from GoDaddy 4GH Hosting to Amazon EC2 using their micro instance.
Here's how I did it.
I am an existing Amazon customer, so I decided to use the same email address and password to access AWS Amazon. I am using Amazon S3 for backup, and use my account to buy books.
HTTP (0.0.0.0/0)
SSH (0.0.0.0/0)
Custom Rule, Port Range 20-21 (0.0.0.0/0)
Custom Rule, Port Range 14000-14050 (0.0.0.0/0)
Here's how I did it.
I am an existing Amazon customer, so I decided to use the same email address and password to access AWS Amazon. I am using Amazon S3 for backup, and use my account to buy books.
- In EC2 Dashboard, you will see "Launch Instance" to initiate your first server at Amazon cloud.
- I've used the Classic Wizard to launch the setup, click continue.
- In choose an AMI, you have the option to select from the Quick Start, My AMIs, Community AMIs, and Marketplace. For this guide, let's use Amazon Linux AMI 2012.03 package, it includes Linux 3.2, AWS tools, and repository access to multiple version of MySQL. I click Select 64 bit to proceed.
- Select Launch Instances, availability zone, select default no preference, then click Continue.
- In Key, I simply use my domain name, click Continue.
- Select "Create a new Key Pair" using your domain name for simple management of keys.
- Choose one or more of your existing Security Groups. I prefer to create a new group for a new project.
HTTP (0.0.0.0/0)
SSH (0.0.0.0/0)
Custom Rule, Port Range 20-21 (0.0.0.0/0)
Custom Rule, Port Range 14000-14050 (0.0.0.0/0)
- Click Launch to finish the setup. I did not create Status Check Alarms, I will go back when the server is in production.
- In My Resources, click the Refresh button to see your new instance.
- Click running instances to see the list of instance.
- Now to manage the server. Select the instance (put check to select the instance). In Instance Actions, select Connect, this will give you option to connect e.g. Connect with a standalone SSH Client and Connect from your browser using the Java SSH Client (Java Required).
- I like Putty SSH tool, so obviously I choose Connect with a stand alone SSH client.
- You need to download the PuTTYgen to convert your private key. Here's a procedure provided by Amazon.
- Let's get an Elastic IP address for the server. In AWS console dashboard, click Elastic IPs, click on Allocate New Address, click Yes, Allocate
- In Addresses, put check on the IP address, then click Associate Address. In Select an instance, choose the instance to associate your IP, click Yes Associate. It will shows in your list of Addresses, IP Address point to your Public DNS.
- Now go to your domain name registrar e.g. NeedName.com, Enom, or GoDaddy. Add A record IP Address to your domain.
- After that, let's begin managing our instance (cloud server). If everything is correctly configured with your PuTTY setup, you should be using your user name (ec2-user) to login, and yes no password required because of your private key.
Now we're connected to the first instance. Let's do update, very important run the following command.
[ec2-user@ip-information-here ~]$ sudo yum update [Enter]
The script will run for about 2-5 minutes depending your Internet bandwidth speed.
Next.
[ec2-user@ip-information-here ~]$ sudo su [Enter]
After you execute sudo su, you're now in super user mode.
[root@ip-information-here ~]$
We have the server but we have nothing configure yet, so let's install Apache Web Server.
[root@ip-information-here ~]$ yum install httpd
Start the service
[root@ip-information-here ~]$ service httpd start
Configure to start httpd service automatically
[root@ip-information-here ~]$ chkconfig httpd on
How about installing PHP? Let install PHP
[root@ip-information-here ~]$ yum install php php-mysql
Restart the Apache web server to introduce PHP
[root@ip-information-here ~]$ service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
And install MySQL database to hold our data.
[root@ip-information-here ~]$ yum install mysql-server
Start MySQL service:
[root@ip-information-here ~]$ service mysqld start
Similar to httpd, we need to start MySQL service automatically:
[root@ip-information-here ~]$ chkconfig mysqld on
Create your first database:
[root@ip-information-here ~]$ mysqladmin -uroot create friended
where friended is the database name
Let us secure our database:
[root@ip-information-here ~]$ mysql_secure_installation
Enter the root current password.
Change root password, and confirm.
Remove anonymous user: Y
Disallow root login remotely: Y
Remove test database and access to it: Y
Reload privilege tables now: Y
I want to install my wordpress in my root directory e.g. /var/www/html.
Check your current directory:
[root@ip-information-here ~]$ pwd
Output:
//home/ec2-user
Change directory to /var/www/
[root@ip-information-here ~]$ cd /var/www
Download the latest copy of Wordpress:
[root@ip-information-here ~]$ wget http://wordpress.org/latest.tar.gz
Extract WordPress:
[root@ip-information-here ~]$ tar -xzvf latest.tar.gz
Move the wordpress directory to the html folder.ec2
[root@ip-information-here ~]$ rmdir html
[root@ip-information-here ~]$ mv wordpress html
Delete the latest.tar.gz copy to clean our install.
[root@ip-information-here ~]$ rm latest.tar.gz
Now, configure the Wordpress install
Change directory to html
[root@ip-information-here ~]$ cd html
[root@ip-information-here ~]$ mv wp-config-sample.php wp-config.php
Edit wp-config.php with your database connection credentials e.g. db name, username, and password.
[root@ip-information-here ~]$ vi wp-config.php
define(‘DB_NAME’, ‘YOUR_DATABASE_NAME’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘YOUR_PASSWORD’);
define(‘DB_HOST’, ‘localhost’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘YOUR_PASSWORD’);
define(‘DB_HOST’, ‘localhost’);
Press ESC, type :wq to save.
Configure your wordpress.
It's easier if you have an FTP Server, let's go ahead and install one for our server.
[root@ip-information-here ~]$ yum install vsftpd
References:
Got some tips from this blog: http://stephen-white.blogspot.com/2012/05/how-to-set-up-wordpress-on-amazon-ec2_31.html
Step-by-step installation of phpMyAdmin to Amazon EC2: http://calebogden.com/wordpress-on-linux-in-the-amazon-cloud-with-mac/
Comments
Post a Comment