Migrating PHP 5.2.x application from Shared Hosting to VPS

Sorry for not post here for long time 🙂 . Getting busy with teaching and consulting make me forgot about this blog. Today I want to share about my experience dealing with php application that run well on 5.2 version. Client need to migrate it to dedicated server but I suggest to check it on vps first before deploy to dedicated server.

The aim of this job is to create a checklist around installation process, modules and others.

For OS I prefer to use Ubuntu server and I used to get it work for Ubuntu LTS (8.04, 10.04 and 12.04). Simply downgrade current PHP version to use Hardy Heron or 9.10 can save my day but now all those option no longer available since Ubuntu close it.

Further search lead me to Debian. Yes, Debian still give me access to Debian 5 repository where PHP 5.2 exist.

A few important things do before  create the server :

1. Choose cheap but good vps provider. I choose Digital Ocean with their $5/month package.

2, Pick Debian 6, 32 bit . (lighter than 64 bit).

3. Change source.list for these lines :

deb http://ftp.us.debian.org/debian squeeze main
deb http://security.debian.org/ squeeze/updates main
deb http://archive.debian.org/debian lenny main contrib non-free

4. Set priority of PHP only use Leny.


Package: *
Pin: release n=lenny*
Pin-Priority: 100
Package: libapache2-mod-php5 php5-dev php5-common php5-curl php5-gd php5-mcrypt php5-mysql php5-cli php5-mhash php5-xsl php5-imap php$
Pin: release n=lenny*
Pin-Priority: 999

5. Install all related lamp package

#apt-get update
#apt-get clean#apt-get install libapache2-mod-php5 php5-common php5-curl php5-gd php5-mcrypt php5-mysql php5-cli php5-mhash php5-xsl php5-imap php5-xmlrpc php5-sqlite

#apt-get install mysql-server

6. Add cache ( I use eaccelerator)

#cd /root
#wget -c http://www.debiantutorials.com/static/eaccelerator-
#apt-get install php5-dev make

#rm /usr/lib/php5/build/ltmain.sh
#ln -s /usr/share/libtool/config/ltmain.sh /usr/lib/php5/build/ltmain.sh

#rm /usr/lib/php5/build/libtool.m4
#ln -s /usr/share/aclocal/libtool.m4 /usr/lib/php5/build/libtool.m4

#cd /usr/share/aclocal
#cat lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 >> libtool.m4

#cd eaccelerator-
#./configure --without-eaccelerator-use-inode
#make install

Configuration :

#nano /etc/php5/conf.d/eaccelerator.ini



#mkdir -p /var/cache/eaccelerator
#chmod 0777 /var/cache/eaccelerator
#/etc/init.d/apache2 restart

Check through phpinfo().

Extra step to protect from php shell alike : (editing php.ini)

disable_functions = dl , exec , passthru , pcntl_exec , pfsockopen , popen , posix_kill , posix_mkfifo , posix_setuid , proc_close , proc_open , proc_terminate , shell_exec , system , leak , posix_setpgid , posix_setsid , proc_get_status , proc_nice , show_source , escapeshellcmd


I can get php application work with 5.2 environment 🙂