This howto explain how to compile and install PHP5.2.x on Debian, to be run as a FastCGI application (Fcgid). This howto also explain how to register this PHP version through the PhpSwitcher plugin.
# cd /usr/local/src # mkdir -p php_buildenv/php52 && cd php_buildenv/php52 # apt-get update && apt-get install build-essential
# apt-get build-dep php5 # apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev \ libssl-dev libc-client2007e libc-client2007e-dev libpq5
# For X86_64 architectures ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a # For i386 architectures ln -s /usr/lib/libc-client.a /usr/lib/i386-linux-gnu/libc-client.a
# wget http://museum.php.net/php5/php-5.2.17.tar.gz # tar -xzf php-5.2.17.tar.gz # cd php-5.2.17
More information about why the sources must be patched are needed.
curl "https://bugs.php.net/patch-display.php?bug_id=54736&patch=debian_patches_disable_SSLv2_for_openssl_1_0_0.patch&revision=1305414559&download=1" -s -o debian_patches_disable_SSLv2_for_openssl_1_0_0.patch.patch patch -p1 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch.patch
# ./configure \ --prefix=/opt/php-fcgid/5.2 \ --with-config-file-scan-dir=/opt/php-fcgid/5.2/conf.d \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --with-pgsql \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-mysql \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-mysqli=/usr/bin/mysql_config \ --with-pdo-mysql \ --with-pdo-pgsql \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --enable-ftp \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-fastcgi \ --enable-cgi \ --enable-force-cgi-redirect \ --with-imap \ --with-imap-ssl \ --with-libdir=/lib/i386-linux-gnu
# ./configure \ --prefix=/opt/php-fcgid/5.2 \ --with-config-file-scan-dir=/opt/php-fcgid/5.2/conf.d \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --with-pgsql \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-mysql \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-mysqli=/usr/bin/mysql_config \ --with-pdo-mysql \ --with-pdo-pgsql \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --enable-ftp \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-fastcgi \ --enable-cgi \ --enable-force-cgi-redirect \ --with-imap \ --with-imap-ssl \ --with-libdir=/lib/x86_64-linux-gnu
Note: If you need more modules, you must tune the configuration options and install needed libraries.
# make # make install
Test your php binary by running the following command:
# /opt/php-fcgid/5.2/bin/php-cgi -v
which should give a result such as (look for the fgci part):
PHP 5.2.17 (cgi-fcgi) (built: Mar 6 2014 17:13:47) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Parameter | Value | Description |
---|---|---|
Name | PHP5.2 (Fcgid) | This is the unique name for the new PHP version |
PHP binary path | /opt/php-fcgid/5.2/bin/php-cgi | This is the path of the PHP binary |
PHP configuration directory | /var/www/fcgi | This is the directory in which customers's PHP configuration files are stored |