This article is about how to install Wordpress on Amazon EC2 with MySQL running on Amazon RDS.
Launch a EBS-backed AMI
In the ec2 console, click launch select Ubuntu Server 12.04.1 LTS 64-bit (AMI id = ami-3d4ff254).
Use t1.micro.
Set delete on termination to false for the root device.
Set termination behaviour to Stop.
Add port 22, 80, 443 for security group
Install Software
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-auth-mysql php5-mysql mysql-client libapache2-mod-php5
We are not going to install mysql-server, since we will be using RDS.
Use Amazon RDS as the database
If you want to set up your own MySQL database, you can do so. For the purpose of this tutorial, we will use Amazon RDS because it takes care of scaling, replication and backups (to S3) without minimim effort.
Read Using MySQL on Amazon RDS to create a MySQL database.
After you created a database, note the database name, username, password, and endpoint address of the DB instance. The endpoint address will be like wordpress.a2ks0zoxdxq.us-east-1.rds.amazonaws.com.
You can ssh into your ec2 instance and run the mysql command to access the database.
mysql -h {endpoint_address} -P 3306 -u{username} -p{password}
Note that when I used a different syntax for the above mysql command, I kept on getting access denied error. Please use the syntax I specified above.
Download Wordpress
sudo mkdir /var/www
cd /var/www
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
rm latest.tar.gz
mv wordpress {name_of_your_blog}
Configure Wordpress
mv wp-config-sample.php wp-config.php
vi wp-config.php
Change these:
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
The DB_HOST will be the endpoint we specified above. Include the port :3306 as well.
Ex. wordpress.a2ks0zoxdxq.us-east-1.rds.amazonaws.com:3306
Generate keys for the following:
https://api.wordpress.org/secret-key/1.1/salt/
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
Configure Apache
cd /etc/apache2/sites-available
cp default wordpress
vi wordpress
Change DocumentRoot and Directory from /var/www/ to your blog's directory.
Change AllowOverride from none to all. (If you don't do this, you can't do pretty links in Wordpress.)
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Save the File.
a2dissite default
a2ensite wordpress
a2enmod rewrite
service apache2 reload
Launch the site
If you are starting a new Wordpress site, access the site from the browser, and following the on screen instruction and you are done.
Porting data from local MySQL to RDS MySQL
To export data:
mysqldump -u{username} -p{password} -h {host} {database} > backup.sql
To import data:
mysql -u{username} -p{password} -h {host} {database} < backup.sql
No comments:
Post a Comment