Scaling-out WordPress – Software installation

Haproxy installation & configuration

apt-get install haproxy
cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg_orig
vi /etc/haproxy/haproxy.cfg

log local0
log local1 notice
maxconn 4096
user haproxy
group haproxy


log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000

listen webcluster
mode http
stats enable
stats auth admin:[PASSWORD]
balance roundrobin
option forwardfor
server tu-web-01 check
server tu-web-02 check
server tu-web-03 check
server tu-web-04 check

vi /etc/default/haproxy
/etc/init.d/haproxy restart


  • I allowed keep-alive connections by removing  “option httpclose”
  • I don’t use any cookie insertion as I will share the sessions between all fronts by storing the sessions in a shared nfs directory

Mysql Master Installation & configuration

To enable more disk space, I resized the disk though the VMware client UI after cloning the VMware template and I resized the partition, the LVM volume group and the file system as followed:
parted mkpart primary 8332MB 24436MB
pvcreate /dev/sda3
vgextend tu-base-01 /dev/sda3
vextend -L 20G /dev/tu-base-01/root
resize2fs /dev/tu-base-01/root 20G

I did a basic installation of mysql:
apt-get install mysql-server
vi /etc/mysql/my.cnf
#bind-address =
#could use the IP of the server
bind-address =

/etc/init.d/mysql restart

WordPress database creation :
mysql –u root -p
mysql> create database mysite;
mysql> create user wdmysite;
mysql> set password for wdmysite = PASSWORD("[PASSWORD]");
mysql> grant all privileges on mysite.* to 'wdmysite'@'%' identified by '[PASSWORD]';
mysql> grant all privileges on mysite.* to 'wdmysite'@'localhost' identified by '[PASSWORD]';
mysql> flush privileges;

In a following post, you will find the configuration I used to enable the read replica

WordPress first Front Installation  & configuration

I used also a very basic configuration
sudo apt-get install apache2
sudo apt-get install mysql-client php5 php5-mysql
sudo vi /etc/hosts tu-web-01 #to avoid warning servername from apache
sudo /etc/init.d/apache2 restart
sudo mv wordpress-3.4.1-fr_FR.tar.gz /var/www
cd /var/www
sudo tar -zxvf wordpress-3.4.1-fr_FR.tar.gz
sudo mv wordpress mysite
sudo chown -R www-data:www-data mysite
sudo rm -rf wordpress-3.4.1-fr_FR.tar.gz
cd /var/www/mysite/
sudo cp wp-config-sample.php wp-config.php
vi wp-config.php
define('DB_NAME', ‘mysite’);
define('DB_USER', 'wdmysite');
define('DB_PASSWORD', '[PASSWORD]');
define('DB_HOST', 'tu-sql-01');
define('DB_CHARSET', 'utf8');
#insert salt from

sudo /etc/init.d/apache2 restart

Then I created a post by copying a page from wikipedia.
I edit the WordPress php header file to allow displaying the hostname as follow:

<h2 id="site-description"><?php bloginfo( 'description' ); echo ":"; $servername=gethostname(); echo $servername; echo ":"; ?></h2>

Second, Third and Fourth Front Installation and Configuration

To create the other fronts, I just cloned the first front VM and changed the name in the following files
/etc/ssh/ /etc/ssh/

go to Introduction


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.