Install databases

apt-get install postgresql mysql-server

Migrate mysql databases

# on the original machine
mysqldump -A --opt --password='nemo' --allow-keywords --flush-logs --hex-blob \ --max_allowed_packet=16M --quote-names > mysql.all.dat
# on the new machine
mysql -u root --password=xxxx < mysql.all.dat

Migrate postgresql databases

# on the original machine
su - postgres -c 'pg_dumpall' > pg_all.dat

# on the new machine
su - postgres -c 'psql' < pg_all.dat

Of course you will have to migrate the databases again just before moving to production but this is to test all applications work ok.

Migrate tomcat

– copy $CATALINA_HOME/webapps
– edit $CATALINA_HOME/conf/{tomcat-users.xml,server.xml}
– install activation.jar, jta.jar and mail.jar in $CATALINA_HOME/common/lib

If you are using javamail in your web application your first time you run your application you will probably get this:

Caused by: java.lang.NullPointerException	
at java.lang.String.concat(String.java:1503)	
at com.sun.activation.registries.MailcapFile.parseLine(MailcapFile.java:235)	
at com.sun.activation.registries.MailcapFile.parse(MailcapFile.java:197)	
at com.sun.activation.registries.MailcapFile.createMailcapHash(MailcapFile.java:157)	
at com.sun.activation.registries.MailcapFile.<init>(MailcapFile.java:40)	
at javax.activation.MailcapCommandMap.loadFile(MailcapCommandMap.java:276)	
at javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:128)

Fortunately this is not an error with your application but a problem with the ubuntu installation. Just remove the -e line from the beginning of your .mailcap file which causes this problem. Here are some links related:

Create a startup script for tomcat

As I did not want to install the multitude of packages ubuntu wants to install for tomcat5.5 I just downloaded the archive and installed it in opt. Here is a simple /etc/init.d/tomcat script:

#! /bin/sh

### BEGIN INIT INFO
# Provides:          tomcat
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: tomcat
# Description:       Controls the apache tomcat
### END INIT INFO

export JAVA_HOME=/opt/java
export CATALINA_HOME=/opt/tomcat
TOMCAT_USER=tomcat
#don't forget to add the tomcat user
#useradd tomcat -d /opt/tomcat -s /bin/false
#chown -R tomcat:tomcat /opt/tomcat

case $1 in
    start)
    su - $TOMCAT_USER -c "$CATALINA_HOME/bin/startup.sh" &
    ;;
    stop)  
    su - $TOMCAT_USER -c "$CATALINA_HOME/bin/shutdown.sh" &
    ;;
    restart)
    su - $TOMCAT_USER -c "$CATALINA_HOME/bin/shutdown.sh" &
    sleep 5
    su - $TOMCAT_USER -c "$CATALINA_HOME/bin/startup.sh" &
    ;;
esac    

exit 0

Install the web server

Install apache

apt-get install apache2 apache2-ssl-certificate libapache2-mod-php5 php5-mysql 
a2enmod ssl 
a2enmod jk

There is not much to say about an apache config except that there are many ways to split it in many files. Most distributions split it differently. This is also the case with ubuntu. What I did was to restore a configuration structure I am used to. However there are a few observations:

CacheSize 10000
CacheGcInterval 2
CacheForceCompletion 100

directives for mod_cache are no longer supported. Cache size configuration is now the responsability htcacheclean which is configured by default as a daemon. Configuration can be found in: /etc/default/apache2.

After correcting the configuration errors the server started and then just crashed with no errors. Even apache2 -e Debug -X -k start did not showed much info. I had to do a:
strace apache2 -e Debug -X -k start in order to see the cause (my bad):

open("/etc/apache2/logs/error_log.len.ro.log", O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE, 0666) = -1 ENOENT (No such file or directory)

The solution was to do a replace on the config files

replace logs/ /var/log/apache2/ — *

Install plone

copy plone universal installer instance
Starting zope-plone gave an error:

/opt/Plone-2.5.3/Python-2.4.4/bin/python: error while loading shared libraries: libstdc++.so.5: 
cannot open shared object file: No such file or directory

which get fixed by installing libstdc++5

apt-get install libstdc++5

create /etc/init.d/zope-plone startup script

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          zope-phone
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

start() {
        echo "Starting Zope in /opt/Plone-2.5.3/zeocluster"
        /opt/Plone-2.5.3/zeocluster/bin/startcluster.sh
        return $?
}

stop() {
        echo "Stopping Zope in /opt/Plone-2.5.3/zeocluster"
        /opt/Plone-2.5.3/zeocluster/bin/shutdowncluster.sh
        return $?
}

restart() {
        echo "Restarting Zope in /opt/Plone-2.5.3/zeocluster"
        /opt/Plone-2.5.3/zeocluster/bin/restartcluster.sh
        return $?
}

case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    *)
    exit 1
esac

Install the zope-plone service

update-rc.d zope-plone defaults