Installing memcached with repcached patch for HA memcache cluster

About

Repcached is an interesting patch for memcached which allows replication between 2 memcached nodes (servers). The purpose of this article is to setup 2 memcached servers that replicate each others.

Note: This article is specifically written for Ubuntu 12.04 and memcached version 1.4.13. It may or it may not work for other versions.

Setup

2x 512MB RackSpace instances called node01(IP 10.0.0.1) and node02(IP 10.0.0.2)

Patch for memcached v1.4.13:
https://github.com/usecide/repcached/blob/master/repcached-2.3.1-1.4.13.patch

Build

Prepare to build the package:

apt-get build-dep memcached
apt-get source memcached
cd memcached-1.4.13
wget https://github.com/usecide/repcached/blob/master/repcached-2.3.1-1.4.13.patch
patch -p1 -i repcached-2.3.1-1.4.13.patch

Now edit the file debian/rules and look for config.status and add –enable-replication like this:

config.status: configure
        dh_testdir
        CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) 
                                       --build=$(DEB_BUILD_GNU_TYPE) 
                                       --prefix=/usr 
                                       --mandir=$${prefix}/share/man 
                                       --enable-replication 
                                       --infodir=$${prefix}/share/info

Now build the package:

dpkg-buildpackage -us -uc -nc
cd ..

You should see a package named memcached_1.4.13-0ubuntu2_amd64.deb. Copy this file on both of your memcached servers and install it using this command:

dpkg -i memcached_1.4.13-0ubuntu2_amd64.deb

Configuration

You are almost done now. Kill all running memcached processes on both nodes:

killall -9 memcached
ps aux | grep memcached

On node01 do the following things:

cp /etc/memcached.conf /etc/memcached_server1.conf

Edit /etc/memcached_server1.conf and replace the line:

-l 127.0.0.1 

with

-l 10.0.0.1

and add at the end:

-x 10.0.0.2

Start memcached:

service memcached start

On node02 do something similar:

cp /etc/memcached.conf /etc/memcached_server2.conf

Edit /etc/memcached_server2.conf and replace the line:

-l 127.0.0.1 

with

-l 10.0.0.2

and add at the end:

-x 10.0.0.1

Start memcached:

service memcached start

Testing

From node01:

telnet 10.0.0.1 11211:
Escape character is '^]'.
get hello
set hello 0 0 4
abcd
get hello
VALUE hello 0 4
abcd

From node02:

telnet 10.0.0.2 11211:
Escape character is '^]'.
get hello
VALUE hello 0 4
abcd

How to setup Galera 3 node cluster on Ubuntu 12.04

Galera is a multi-master replication solution for MySQL, which provides an interesting alternative to the standard master-master MySQL replication we are all so used with. One main advantage of Galera is the ability of doing sync replication, thus reducing the risk of data inconsistency between masters.

Setup on RackSpace Cloud

3x 512MB RAM instances, with 20GB storage space
1x Load Balancer for MySQL, RoundRobin algorithm, Health check enabled
1x 512MB RAM instance for testing
OS: Ubuntu 12.04 LTS 64bit

Goal:

Quickly setup a Galera cluster and run some benchmarks using sysbench.

Note: For the sake of simplicity I will refer to the Galera instances as node01, node02 and node03. The test instance will be referred as test01.

Common settings on all nodes

On every node execute:

  1. An apt-get update and upgrade to bring the instances up to date.
  2. Install required packages
    apt-get install libaio1 libssl0.9.8 mysql-client libdbd-mysql-perl libdbi-perl
  3. Download Galera wsrep provider
    wget https://launchpad.net/galera/2.x/23.2.4/+download/galera-23.2.4-amd64.deb
    dpkg -i galera-23.2.4-amd64.deb
  4. Download MySQL server with wsrep patch
    wget https://launchpad.net/codership-mysql/5.5/5.5.28-23.7/+download/mysql-server-wsrep-5.5.28-23.7-amd64.deb
    dpkg -i mysql-server-wsrep-5.5.28-23.7-amd64.deb
  5. I had some issues and I had to create /var/log/mysql
    mkdir -pv /var/log/mysql
    chown mysql:mysql -R /var/log/mysql
  6. Secure the mysql installation and assign a good password to root user:
    service mysql restart
    mysql_secure_installation
  7. Create an user for galera nodes to use for connect/replication
    mysql -p
    mysql> grant all privileges on *.* to galera@'%' identified by 'password';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> set global max_connect_errors = 10000;
    Query OK, 0 rows affected (0.01 sec)
  8. Edit /etc/hosts and make sure you add all the nodes and their corresponding IPs

Galera setup for each node

Edit the /etc/mysql/conf.d/wsrep.cnf and change the values for the following variables:

Configuration for node01:

wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="galera"
wsrep_cluster_address="gcomm://"
wsrep_sst_method=mysqldump
wsrep_sst_auth=galera:password

Configuration for node02:

wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="galera"
wsrep_cluster_address="gcomm://node01:4567"
wsrep_sst_method=mysqldump
wsrep_sst_auth=galera:password

Configuration for node03:

wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="galera"
wsrep_cluster_address="gcomm://node02:4567"
wsrep_sst_method=mysqldump
wsrep_sst_auth=galera:password

Testing the setup

Now restart mysql on all the nodes and check out if cluster is working:

service mysql restart
mysql -p
mysql> show status like 'wsrep%';
+----------------------------+-------------------------------------------------------------+
| Variable_name | Value |
+----------------------------+-------------------------------------------------------------+
| wsrep_cluster_size | 3 |
| wsrep_ready | ON |
+----------------------------+-------------------------------------------------------------+

One more thing before you are done:
Edit node01 wsrep_cluster_address=”gcomm://node3:4567″ and restart mysql server.

Benchmarks were performed from test01 instance using sysbench 0.5 OLTP read-only complex test:

sysbench OLTP (ro) Galera cluster transactions vs threads
ThreadsTransactions/s
115
225
449
8103
16205
32390
64506
128653

galera-transactions-threads

sysbench OLTP (ro) Galera cluster avg response time
ThreadsAvg response timeMin response timeAprox 95%
16642131
27953135
48042153
87742136
167743143
328142142
6412548322
12819445427

galera-response-times

Benchmark Galera cluster vs MySQL master-master on RackSpace

Setup:

Before starting this I would like to point out that I have compared 2 instances(master-master) vs 3 instances(galera cluster) so the test is not correct/accurate. It’s more of a “what if I switch from master-master replication to 3 nodes galera”.

MySQL Master-Master replication:

2x 512 MB instances with 20GB of storage, Ubuntu 12.04 64bit, mysql-server 5.5 was used with no optimization changes to my.cnf, except the required changes for master-master replication.
1x LoadBalancer, RoundRobin algorithm

Galera 3 nodes cluster:

3x 512 MB instances with 20GB of storage, Ubuntu 12.04 64bit, mysql-server 5.5 from galera was used, with no changes to my.cnf, only required node changes were made wsrep.cnf.
1x LoadBalancer, RoundRobin algorithm

Test instance:

1x 512MB instance with 20GB of storage, Ubuntu 12.04 64bit running sysbench

sysbench --test=oltp --mysql-host=loadbalancer_ip --mysql-user=root --mysql-password=password--oltp-table-size=1000000 prepare

The tests were performed on a database of about 256MB size, InnoDB table(s). No optimization changes were made to default my.cnf files, except the required to setup replication.

sysbench OLTP transactions per second
TestMaster-MasterSingle nodeGalera cluster
1 thread,3m10.9717.1112
16 threads,1m, rw1541400
16 threads,1m, r only217158.7206
32 threads,1m, r only325160.79375

galera-cluster-vs-master-master

As you can see from the table and graph I had some issues performing sysbench for Galera cluster in rw mode for 16 threads. From what I have found on Internet it’s an issue with sysbench 0.4.12 so I will attempt to rerun the tests with a newer version.

Installing Scalr 3.5 Open Source on Ubuntu 12.04

This is an update on an older post of mine, one of my first articles regarding cloud computing. Much has changed since since 2008 when I have wrote this article “How to install Scalr on Ubuntu 8.10 EC2 Instance“.

For example the Ubuntu has evolved to 12.04 LTS (I am using LTS 64bit for this howto) and Scalr is now version 3.5. One thing didn’t change: it’s still a royal PITA to get Scalr open source working. Hopefully this howto will help you to install Scalr on your server. It doesn’t cover operating Scalr and other things, which I will address in future posts, if there is enough interest.

After you have installed Ubuntu 12.04 64bit server edition to your server or virtual machine the way you like it it’s time to start the update process:

apt-get update && apt-get upgrade

Now you are ready to run tasksel and select the following roles for your server: OpenSSH, DNS server, LAMP server

You will need to install some dev packages before going anything else:

apt-get install libcurl4-gnutls-dev make librrd-dev

Now it’s time for PHP5 related extensions:

apt-get install php5-curl php-gettext php-net-socket php5-mcrypt php-xml-serializer libssh2-php php-soap php5-snmp php5-rrd
pecl install pecl_http
echo "extension=http.so" >/etc/php5/conf.d/pecl_http.ini
pecl install rrd
echo "extension=rrd.so" >/etc/php5/conf.d/rrd.ini

Time to get Scalr code:

cd /tmp
wget http://bit.ly/scalr35
tar zxvf scalr35
cd scalr-3.5.r7704
cp -r app /var/www/
chown -R www-data:www-data /var/www/app

Create new database and import sql from sql/scalr:

mysql -p
mysql> CREATE DATABASE scalr CHARACTER SET latin1 COLLATE latin1_swedish_ci;
mysql> grant all privileges on scalr.* to scalr@localhost identified by 'password';
mysql> flush privileges;
mysql> quit
mysql -p scalr <sql/scalr.sql

While doing that import I’ve got a nice error:
ERROR 1054 (42S22) at line 2222: Unknown column ‘architecture’ in ‘field list’
Fix:
1) Drop database
2) Search sql/scalr.sql for “CREATE TABLE IF NOT EXISTS `role_images`” and add after platform:

`architecture` varchar(25) DEFAULT NULL,
`os_family` varchar(25) DEFAULT NULL,
`os_name` varchar(25) DEFAULT NULL,
`os_version` varchar(25) DEFAULT NULL,
`agent_version` varchar(25) DEFAULT NULL,

Reference:https://groups.google.com/forum/?fromgroups=#!topic/scalr-discuss/ApCGfrNXqz8

Configuration of Scalr is quite simple:

cd /var/www/app/etc
cp config.ini-sample config.ini
edit config.ini

Cron jobs required by Scalr? Just type crontab -e and add the following lines:

*/2 * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --Poller
* * * * * /usr/bin/php -q /var/www/app/cron/cron.php --Scheduler2
*/10 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --MySQLMaintenance
* * * * * /usr/bin/php -q /var/www/app/cron/cron.php --DNSManagerPoll
17 5 * * * /usr/bin/php -q /var/www/app/cron/cron.php --RotateLogs
*/2 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --EBSManager
*/20 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --RolesQueue
*/5 * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --DbMsrMaintenance
*/2 * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --Scaling
*/5 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --DBQueueEvent
*/2 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --SzrMessaging
*/4 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --RDSMaintenance
*/2 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --BundleTasksManager
* * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --ScalarizrMessaging
* * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --MessagingQueue
*/2 * * * * /usr/bin/php -q /var/www/app/cron-ng/cron.php --DeployManager
*/2 * * * * /usr/bin/php -q /var/www/app/cron/cron.php --UsageStatsPoller
* * * * * root /usr/bin/php -q /var/www/app/cron-ng/cron.php --SNMPStatsPoller

Time to add a Virtual Host:

cat <<EOF> /etc/apache2/sites-available/scalr
<VirtualHost *:80>
ServerName scalr.example.com
ServerAdmin webmaster@example.com
DocumentRoot "/var/www/app/www"

<Directory "/var/www/app/www">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF

Enable required Apache modules and site and restart everything:

a2ensite scalr
a2enmod rewrite
service apache2 restart

DNS managed by bind9:

chmod g+w /etc/bind/named.conf
echo 'include "/var/named/etc/namedb/client_zones/zones.include";' >> /etc/bind/named.conf
mkdir -p /var/named/etc/namedb/client_zones
chown root.bind /var/named/etc/namedb/client_zones
chmod 2775 /var/named/etc/namedb/client_zones
echo ' ' > /var/named/etc/namedb/client_zones/zones.include
chown root.bind /var/named/etc/namedb/client_zones/zones.include
chmod g+w /var/named/etc/namedb/client_zones/zones.include

To get rid of nasty AppArmor warnings and errors edit /etc/apparmor.d/usr.sbin.named and add:

/var/named/etc/namedb/client_zones/zones.include rw,

And finish it by restarting AppArmor and bind9:

service apparmor restart
service bind9 restart

Open your browser and go to http://scalr.example.com. Default username/password: admin/admin.

If you have issues or you need more info please feel free to comment 🙂

Enable passive mode for Pure-ftpd on AWS

One of the issues you encounter when installing FTP servers on AWS is that you need to user Active mode to transfer files, while traditionally FTP clients tend to use Passive mode (PASV). This is caused by the fact that each instance has an external IP that you get access to and another internal IP, which is used by the FTP server. When the client requests PASV mode, the server replies with the internal IP, which of course is non-routable(is that the correct word?).

Fixing this is quite easy, it involves a little bit of editing Security Groups from AWS Console and adding a couple of lines.

First of all you will need to determine what port range you can use for PASV mode, so execute this command:

cat /proc/sys/net/ipv4/ip_local_port_range

You must choose a range that’s *not* in the interval returned by the command. I will use 10000 – 10100.
Now you will need to find out your external IP. Either request an Elastic IP and attach it to the instance or ping your “Public DNS”(available in the AWS Console, when you select the instance). Write it down somewhere.

Now open the required ports from your “Security Groups”, by adding the following rules:

Custom TCP Rule Ports 20-21
Custom TCP Rule Ports 10000-10100

Don’t forget to “Apply Rule Changes”!!!
Depending on your pure-ftpd installation you may have your FTP server configuration either in /etc/pure-fptd.conf or in /etc/pure-ftpd/conf/*. If you have your configuration in a single file (/etc/pure-ftpd.conf) then you will need to add these 2 lines:

PassivePortRange 10000 10100
ForcePassiveIP YOUR_EXTERNAL_IP_HERE

If you have your configuration in /etc/pure-ftpd/conf/* simply create two files, named after the options you want to change and insert the values into them:

echo "10000 10100" > /etc/pure-ftpd/conf/PassivePortRange
echo "YOUR_EXTERNAL_IP_HERE" > /etc/pure-ftpd/conf/ForcePassiveIP

Obviously you will need to replace YOUR_EXTERNAL_IP_HERE with your real external IP.

Now restart your FTP server and check that you see something similar to “-P YOUR_EXTERNAL_IP -p 10000:10100” in the parameter list. If everything went ok, congratulations!

service pure-ftpd-mysql restart

MySQL errors after update , error 1018 (HY000), errno: 24

Today I’ve updated MySQL server on one of my Ubuntu 12.04 servers. After the upgrade finished, shock and horror: all websites were down, WordPress sites were presenting install page. Quickly connected to mysql via CLI and tried to see if the databases are still there:

mysql> show databases;
ERROR 1018 (HY000): Can't read dir of '.' (errno: 24)

I’ve tried setting limits as in this article, but that didn’t seem to help. Only after adding “open-files-limit = 2048” to my.cnf and restarting the MySQL server things went back to normal. So a big thank you to the author of the article, but I would like to know if there is any need setting those limits or not(obviously I was stressed out over the web sites being down and didn’t test all things).

Anyone else has any experience with this problem?

Freelancer acquires vWorker

Today I’ve received an email from Freelancer.com letting me know that they have acquired vWorker.com (RentACoder for older freelancers). I was quite shocked by this news as I never expected that a big site like vWorker will be bought. But life goes on and nothing stays the same forever. I have to say that so far I really enjoy Freelancer’s interface a lot more than vWorker. It’s clean, it’s modern and it’s logical. Even after the face lift vWorker did some time ago the site looked dated and wasn’t very intuitive.

I am still waiting for Freelancer to import my project ratings, I hope they will do it soon. Without rating is really really hard to get a job on a freelancing site. But while I wait for them I’ve already made a bid to check the process. So far I like what I see, it seems very clean and intuitive. I’ve also checked the taxes (10% for free account and 3% for premium) which are not that bad.

One thing that drives me nuts is the “Skills” section. Although I have checked many skills it only displays 5 for my Freelancer profile, while for my Employer profile it displays a lot more. I don’t get it. I’ll probably contact their support, maybe they can enlighten me.

The Portfolio section is beautiful, I cannot even compare to what vWorker had. It’s exactly what you need to display your work.

I’ll update the article as I discover more things (hopefully pleasant) on Freelancer. Meanwhile if you need my services you can click on the button bellow and give me a job on Freelancer.com

LE: One day later and I have all my ratings and projects imported. Good work Freelancer!
PHP Developer

Installing MongoDB PECL extension

The MongoDB PECL extension has not been installed or enabled

If you have installed MongoDB and you get the above error or something similar to it, you will need to install the php extension. It’s quite easy, shouldn’t take more than a couple of minutes. All the commands were executed as root, if you want to use the sudo mechanism, just prefix all the commands with sudo.

Install the required packages

apt-get install php-pear php5-dev make

If everything went ok, simply install the extension by executing this command:

pecl install mongo

Activate the MongoDB extension

I have Ubuntu 12.04 server edition installed on the server so I simply added a new ini file containing one line:

echo "extension=mongo.so" > /etc/php5/apache2/conf.d/mongo.ini

Now restart web server (in my case Apache 2.2) and enjoy:

service apache2 restart

mod_fcgid: HTTP request length exceeds MaxRequestLen

Symptoms:
When trying to upload a file you get “Error 500, Internal server error”. In the error log file you get something like:

[Tue Aug 21 20:40:39 2012] [warn] [client x.x.x.x] mod_fcgid: HTTP request length 132532 (so far) exceeds MaxRequestLen (131072), referer: http://www.example.com/upload.php

This problem is present in ISPConfig 3 running on Ubuntu 12.04, when running Apache2 with mod_fcgid.

Fix:
Edit “/etc/apache2/mods-available/fcgid.conf” and add:

FcgidMaxRequestLen  1073741824

Server setup ISPConfig 3 with Ubuntu 12.04

Note: This is work in progress! You should probably test this in a virtual machine first and play around with various settings.

There are a lot of tutorials over the Internet about how to configure an Ubuntu server for ISPConfig. I usually follow them, after all there aren’t so many variations on how to setup a LAMP. But I always find some things that bother me. I don’t claim my setup is “perfect”, but please read and make your own decisions.

Installing Ubuntu 12.04

Disk Partitioning

First of all, do yourself a favor and use at least 2 HDDs for the server you are going to setup. It doesn’t matter if they are of different sizes as long you have enough space on the smallest one. If they have same size, the better. The reason why I am insisting on using at least 2 HDDs is because you will be able to setup software RAID1. There are pro and cons of using software RAID1, but I think it’s better to have it. It’s not even hard to configure RAID1:

  • create 2 equal size partitions, one on each drive
  • mark them as “Use as: physical volume for RAID”
  • go to “Configure software RAID” and “Create MD device” -> RAID1, 2 disks, 0 spare and select the two partitions you have marked for RAID (probably /dev/sda1 and /dev/sdb1)

You should see now RAID1 device #0 which is commonly known as /dev/md0. Congrats, you have just finished setting up software RAID1! Press Alt+F2, Enter and check out the progress of RAID sync:

cat /proc/mdstat

Note: If you are using a system that has (U)EFI you might want to partition your disks before using GParted and you will need to create an EFIBoot partition of about 100MB at the beginning of HDD. To keep things looking nice you can create 2x 128MB partitions on both harddisks(one on each). More details about this on my previous article “Install Ubuntu 12.04 with RAID/LVM on UEFI system”

I prefer to use LVM over the RAID1 I’ve just created because I find it easier to manage this way. I usually create different logical volumes/partitions for:

  • /boot: this one is usually 128MB, for kernel; you skip it if you want
  • /: make this one about 10-20GB, for system
  • /tmp: can be anywhere from 2GB to 10GB, set nosuid and noexec for it
  • /var: this is where there are web files and databases, so I usually use the rest of the space for it; also set usrquota and grpquota for this

If you are using UEFI:You will need 1 vfat32 partition for EFIBoot and 1 ext4 partition for /boot, outside the software RAID. After playing around with all kinds of setups, this was the only working solution I have found. The bad thing with this setup is that in case of disk failure you will have to recover either EFI partition or/and the /boot partition. Sorry, it sucks, but I didn’t find a better way to do it.

Here is how to setup LVM

You can use LVM over RAID1 or simply use LVM. Here are the steps:

  • “Configure the Logical Volume Manager” and use /dev/md0 as Physical Volume.
  • Create a Volume Group and named it “VolGroup00” (or whatever you want)
  • Create as many Logical Volumes as you need, set the right size for them (you can resize later). I usually name them LogVolRoot (for /) or LogVolTmp (for /tmp)
  • When you are done click “Finish”

You now have successfully setup LVM over RAID1. Just one more step and you are done partitioning. For each of the LVMs you have created, click on them and set the following:

  • Use as: file system of your choice; I use XFS because of fs freeze and resize on the fly, feel free to use ext4 or whatever you like most in the end I used ext4 because of quota issues with ISPConfig 3
  • Format the partition: yes
  • Mount point: put here where you want to mount it (be it /, /boot, /tmp, /var, /srv)
  • Mount options: set nosuid and noexec for /tmp and usrquota and grpquota for /var if you have them

Note: About swap partition(s) … there are many approaches to this. You can have 2 swap partitions, one on each drive, set same priority for both and put them outside RAID/LVM. Or you can create a LV for swap. If the harddisks don’t have the same size you can create the swap on the free space left. Recommended swap size is (according to RHEL) 2* RAM if you have less than 2GB, and 2+ RAM if you have over 2GB. I had 2 HDDs, one of 500GB and one of 250GB so I created the swap on the free space left on the big drive. The rest of the space I’ve created a partition, put XFS on it and mounted in /srv for later use (probably some FTP storage, whatever is not important)

Installing software and ISPConfig 3

For the most part I’ve followed this excellent tutorial The Perfect Server – Ubuntu 12.04 LTS (Apache2, BIND, Dovecot, ISPConfig 3), but there are some minor things changed.

First of all I don’t like to disable AppArmor as suggested in the tutorial. From my experience is not that hard to figure out when you screwed up things. Most of the times you will have problems with AppArmor if you change data_dir for MySQL or you made changes to Apache, etc. If you have recently made changes to configuration of MySQL(let’s say you have moved database files from /var/lib to /srv/mysql) and the server is not starting up take a quick look at /var/log/syslog and look up for apparmor entries. If you see something like denied, edit the file /etc/apparmor.d/usr.sbin.mysqld and try to find the entries related to the directories modified. For /var/lib you will find 2 entries similar to these:

  /var/lib/mysql/ r,
  /var/lib/mysql/** rwk,

Either replace /var/lib with /srv/mysql or append 2 new lines, your choice. Restart AppArmor and this should be all. MySQL should start now.

Also in the tutorial at some point you are advised to comment out this line in /etc/mysql/my.cnf:

bind-address           = 127.0.0.1

You only need to do this if you plan to access the MySQL server/databases from another server(you have the website files on another server, you need to set replication). But if all you want to do is to run web sites that use “host= localhost” for their database settings don’t comment out that line. Most of the times you should be fine with MySQL listening only on local interface.

Install MySQL

apt-get install mysql-client mysql-server
mysql_secure_installation

I know there is a lot of debate about using innodb_file_per_table, but after getting a corrupted ibdata1 file and losing all the InnoDB tables I will go with having 1 file per table.

Install Apache2 + PHP-FPM

apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libruby libapache2-mod-ruby

Also I found I was missing php5-curl package:

apt-get install php5-curl

Enable required mods:

a2enmod suexec rewrite ssl actions include

If you plan to use PHP-FPM and fastcgi mod (available in ISPConfig 3.0.5 or svn release):

apt-get install libapache2-mod-fastcgi php5-fpm
a2enmod fastcgi

Install Postfix and Courier

I am only installing Postfix without Amavis and AV/AS capabilities since I am planing to integrate ISPConfig with Zimbra in the future. I find SquirrelMail to be dated and I prefer the modern look and all the features available in the Zimbra Open Source edition. More on the integration of ISPConfig and Zimbra in a future article. Back to work:

apt-get install postfix postfix-mysql postfix-doc openssl getmail4
apt-get install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl courier-maildrop

Install PureFTPD

apt-get install pure-ftpd-common pure-ftpd-mysql

Install BIND (named, DNS)

apt-get install bind9 dnsutils

Install fail2ban and rkhunter

apt-get install fail2ban rkhunter binutils

Vlogger, Webalizer, Awstats

If you don’t use Awstats you can comment out all the entries in /etc/crond.d/awstats.

apt-get install vlogger webalizer awstats geoip-database libclass-dbi-mysql-perl

Quota tools

apt-get install quota quotatool

Install ISPConfig 3

cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/
php -q install.php

Fix /etc/postfix/master.cf:

sed -i -e 's/smtpd_bind_address/smtp_bind_address/' /etc/postfix/master.cf

In case you have missed the note at the top of the article: This is Work in Progress!