WordPress, multiple domains, AWS Linux micro

This is a part of a larger investigation to see how, or if, WordPress scales as a Content Management System on an Amazon Web Services EC2 Linux Micro Instance. This instructional could be disassembled in a myriad of ways to fit a number of Linux, UNIX, and even Windows environments (as WordPress is know to run on any system which supports PHP and MySQL). With this scenario, and the others forthcoming, we’re working with several second-level domains and a single subdomain, respectively. Each domain has an independent, static site (eg, mydomain.com, www.mydomain.com) which is built without WordPress. Each domain also has an accompanying subdomain of blog.mydomain.com which is managed by WordPress. Although it’s possible to manage an entire site with WordPress, beyond the blog application, that’s currently beyond the scope of this exercise.

So roughly, the site structure is this:

mydomain.com, www.mydomain.com
blog.mydomain.com

herdomain.com, www.herdomain.com
blog.herdomain.com

hisdomain.com, www.hisdomain.com
blog.hisdomain.com

The sites are being built and launched with the following supporting mechanisms:

– Amazon Web Services (Linux, Micro Instance)
– Apache (Virtual Hosts)
– MySQL
– WordPress
– Memcache (to support the WordPress W3 Plugin)

Note that WordPress does have a project which supports multiple sites upon a single installation. This is called WordPress MU, or more recently referred to as WordPress Multisite or WordPress with Networks. * We tried working with this type of installation but … didn’t work out. It doesn’t support the following scenario …

Permissions Issue:

http://www.chrisabernethy.com/why-wordpress-asks-connection-info/

# need
php-mysql
php
mysql
mysql-server

– Download and position the wordpress installation bundle:

# mkdir /usr/local/wordpress/blog.mydomain.com
# mkdir /usr/local/wordpress/blog2.mydomain.com
# cd /usr/local/wordpress 

# wget http://wordpress.org/latest.tar.gz
# gunzip latest.tar.gz
# tar -xvf latest.tar
# mv wordpress blog.mydomain.com
# tar -xvf latest.tar
# mv wordpress blog2.mydomain.com

*** After untarring wordpress, check all files are owned by root

– Apache Virtual Domains

# wordpress_001 / blog.mydomain.com
# wordpress_002 / blog2.mydomain.com

### DO NOT FORGET THE ALLOWOVERRIDE DIRECTIVE FOR .HTACCESS

* note that we will change this to includes later in plugin section

* OR DO NOT DO ALLOWOVERRIDE HERE – DO IT LATER, THE RIGHT WAY

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /usr/local/wordpress/blog.mydomain.com

<Directory /usr/local/wordpress/blog.mydomain.com/>
AllowOverride Fileinfo
</Directory>

ServerName blog.mydomain.com
ErrorLog logs/blog.mydomain.com-error_log
CustomLog logs/blog.mydomain.com-access_log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /usr/local/wordpress/blog2.mydomain.com

<Directory /usr/local/wordpress/blog2.mydomain.com/>
AllowOverride Fileinfo
</Directory>

ServerName blog2.mydomain.com
ErrorLog logs/blog2.mydomain.com-error_log
CustomLog logs/blog2.mydomain.com-access_log common
</VirtualHost>

Test:

* do this with info.php ???
<?php phpinfo(); ?>

echo blog >/usr/local/wordpress/blog.mydomain.com/index.html
echo blog2 >/usr/local/wordpress/blog2.mydomain.com/index.html

– Mysql Database

mysql> create database wordpress_001;
mysql> CREATE USER ‘wpadmin_001’@’localhost’ IDENTIFIED BY ‘wppassword’;
mysql> grant all privileges on wordpress_001.* to ‘wpadmin_001’@’localhost’;
mysql> flush privileges;

* now make sure this looks fine…

mysql> select host, user, password from mysql.user;
mysql> show grants for ‘wpadmin_001’@’localhost’;

* For the second install blog2.mydomain.com

mysql> create database wordpress_002;
mysql> CREATE USER ‘wpadmin_002’@’localhost’ IDENTIFIED BY ‘wppassword’;
mysql> grant all privileges on wordpress_002.* to ‘wpadmin_002’@’localhost’;
mysql> flush privileges;
mysql> select host, user, password from mysql.user;
mysql> show grants for ‘wpadmin_002’@’localhost’;

– WordPress wp-config.php

* can we move this to another location ???
* OR at least
chmod 640 wp-config.php
chown root.apache wp-config.php

/usr/local/wordpress/blog.mydomain.com/wp-config.php

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/* define(‘DB_NAME’, ‘database_name_here’); */
define(‘DB_NAME’, ‘wordpress_001’); 

/** MySQL database username */
/* define(‘DB_USER’, ‘username_here’); */
define(‘DB_USER’, ‘wpadmin_001’);

/** MySQL database password */
/* define(‘DB_PASSWORD’, ‘password_here’); */
define(‘DB_PASSWORD’, ‘wppassword’);

/usr/local/wordpress/blog2.mydomain.com/wp-config.php

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/* define(‘DB_NAME’, ‘database_name_here’); */
define(‘DB_NAME’, ‘wordpress_002’);

/** MySQL database username */
/* define(‘DB_USER’, ‘username_here’); */
define(‘DB_USER’, ‘wpadmin_002’);

/** MySQL database password */
/* define(‘DB_PASSWORD’, ‘password_here’); */
define(‘DB_PASSWORD’, ‘wppassword’);

– WordPress Installation

Point browser to:

http://blog.mydomain.com/wp-admin/install.php

– MEMCACHE Install

http://www.lullabot.com/articles/installing-memcached-redhat-or-centos

# yum install memcached
# service memcached start
# chkconfig memcached on

# yum install php-pear
# yum install php-devel
# yum install gcc
# yum install zlib-devel
# yum install make

# pecl install memcache
[ take any default option offered here ]

# vi /etc/php.d/memcache.ini

extension=memcache.so

restart apache here

Create php info() file in DocumentRoot

NOW point a browser to http://yourwebsite.com/info.php

scroll down to find a section on this page with the
rubric “memcache”

memcache support    enabled