Migrating from Apache2 to Lighttpd: Part 1 - Installing FastCGI, PHP5, Zend, eaccelerator
Okay guys,
Before migrating to Lighttpd,
we need to recompile PHP to support FastCGI.
Folow the guide step by step.
It won’t take five minutes.
Promise 
In case you messed up somewhere.
DON’T WORRY, it’s just one email / comment away
Step 1)
Prepare location for installer
mkdir -p /root/INSTALL cd /root/INSTALL
Step 2)
Install FastCGI
wget http://www.fastcgi.com/dist/fcgi.tar.gz tar -zxvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0 ./configure make make install cd ..
Step 3)
Rebuild PHP to support FastCGI
wget http://files.directadmin.com/services/customapache/php-5.2.9.tar.gz wget http://files.directadmin.com/services/customapache/php-5.2.9-mail-header.patch tar -zxvf php-5.2.9.tar.gz patch -p0 < php-5.2.9-mail-header.patch cd php-5.2.9 ./configure --enable-soap --with-libxml-dir=/usr/include/libxml2 \ --with-curl=/usr/local/lib --with-gd \ --enable-gd-native-ttf --with-ttf --with-gettext \ --with-jpeg-dir=/usr/local/lib \ --with-freetype-dir=/usr/local/lib --with-kerberos \ --with-openssl --with-mcrypt --with-mhash \ --with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config \ --with-pdo-mysql=/usr/bin/mysql \ --with-pear --with-png-dir=/usr/local/lib \ --with-zlib --with-zlib-dir=/usr/local/lib --enable-zip --with-iconv=/usr/local \ --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets \ --enable-mbstring --with-curlwrappers --enable-shared --enable-static \ --enable-fastcgi --enable-force-cgi-redirect make make install cd ..
Step 4)
Install Zend Optimizer
wget http://files.directadmin.com/services/customapache/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz cd ZendOptimizer-3.3.3-linux-glibc23-i386 ./install.sh ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER ENTER cd ..
Step 5)
Install eaccelerator
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2 tar -xjvf eaccelerator-0.9.5.3.tar.bz2 cd eaccelerator-0.9.5.3 make clean export PHP_PREFIX="/usr/local" $PHP_PREFIX/bin/phpize ./configure \ --enable-eaccelerator=shared \ --with-php-config=$PHP_PREFIX/bin/php-config make clean make make install cd ..
Remember the location….
| [root@server eaccelerator-0.9.5.3]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ |
If you forgot the location of your eaccelerator,
find it using this command:
locate eaccelerator.so
Find the location of your php.ini
php -r "phpinfo();" | grep php.ini Configuration File (php.ini) Path => /usr/local/lib Loaded Configuration File => /usr/local/Zend/etc/php.ini
Now, edit php.ini
vi /usr/local/Zend/etc/php.ini
and add / modify this line…
| [Zend] zend_extension=”/usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so” zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3 zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3 zend_optimizer.version=3.3.3 zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so eaccelerator.shm_size=”16″ eaccelerator.cache_dir=”/tmp/eaccelerator“ eaccelerator.enable=”1″ eaccelerator.optimizer=”1″ eaccelerator.check_mtime=”1″ eaccelerator.debug=”0″ eaccelerator.filter=”" eaccelerator.shm_max=”0″ eaccelerator.shm_ttl=”0″ eaccelerator.shm_prune_period=”0″ eaccelerator.shm_only=”0″ eaccelerator.compress=”1″ eaccelerator.compress_level=”9″ |
Create cache directory for eaccelerator
mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator
Step 6)
Check your php version
Make sure all work fine before we restart apache.
DO NOT restart apache before passing this step.
eaccelerator and Zend must be loaded properly…
| [root@server eaccelerator-0.9.5.3]# php -v PHP 5.2.9 (cli) (built: Mar 23 2009 12:19:57) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies |
php-cgi was compiled as fastcgi —> cgi-fcgi
| [root@server eaccelerator-0.9.5.3]# php-cgi -v PHP 5.2.9 (cgi-fcgi) (built: Mar 23 2009 12:19:24) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies |
Step 7)
Restart apache
service httpd restart
Step 8 9 10 ….
Troubleshooting 
and take a break.
Next … installing Lighttpd