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


global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon

defaults

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

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

vi /etc/default/haproxy
ENABLED=1
/etc/init.d/haproxy restart

Rem:

  • 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 = 127.0.0.1
#could use the IP of the server
bind-address = 0.0.0.0

/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
127.0.1.1 tu-web-01.myroch.com tu-web-01 #to avoid warning servername from apache
sudo /etc/init.d/apache2 restart
cd
wget http://fr.wordpress.org/wordpress-3.4.1-fr_FR.tar.gz
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 https://api.wordpress.org/secret-key/1.1/salt/

sudo /etc/init.d/apache2 restart
http://tu-web-01/mysite/wp-admin/install.php

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/hostname
/etc/hosts
/etc/ssh/ssh_host_dsa_key.pub /etc/ssh/ssh_host_rsa_key.pub

go to Introduction

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

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