Browsed by
Category: MySQL

Installing WordPress

Installing WordPress

One of the most recommended exercises for learning AWS is the installation of a working WordPress site. This exercise appealed to me in particular because I have a strong background with WordPress development, so it is a technology very familiar to me. I also decided that as part of this exercise I would utilize Route 53 to register a new domain name, and then point my new domain to WordPress installation. A number of steps I implemented used this helpful article as a guide.

I attempted to set up my WordPress installation via a script run during the initial EC2 Instance setup. It didn’t work the first time, but after tweaking it some, here is what I came up with.

yum -y update
yum install httpd
service httpd start
yum install php php-mysql
service httpd restart
yum install mysql-server
service mysqld start
mysqladmin -uroot create dbname
cd /var/www/html
tar -xzvf latest.tar.gz
mv wordpress website_directory
cd website_directory
mv wp-config-sample.php wp-config.php

There are some challenges with this script that need to be worked out:

  1. It doesn’t automatically secure the MySQL root account.
  2. It doesn’t set the correct WordPress ownership and directory permissions.
  3. It installs the MySQL server on the same host as WordPress web server. This means that if you auto-scale these instances, each instance will point to a separate database, which of course is not feasible. So this script should be considered as an exercise only.

Here are some commands from various web articles I ended up using in my installation:

Set Correct WordPress permissions
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

If Setting Hostname after WP install, need to manually change hostname in wp-config.php

Apache should own the html directory contents
chown -R apache:apache *

Change AllowOverride None to AllowOverride All in the section of /etc/httpd/conf/httpd.conf

MySQL Status
mysqladmin -u root -p status

List Databases
mysql –user=your-user-name –password=your-password
mysql> show databases;

Secure Database Server

Create Database
mysql> CREATE DATABASE databasename;

I ended up installing a MySQL database server on a separate EC2 instance so that my environment could be scalable. I plan to write about that soon, as well as my exercise in replicating this environment in CloudFormation.