New Post has been published on Mocco
New Post has been published on http://mocco.sk/tips-on-how-to-use-php-4-4-9-fastcgi-with-apache-ispconfig-3-debian-wheezy/
Tips on how to Use PHP 4.4.9 (FastCGI) With Apache & ISPConfig 3 (Debian Wheezy)
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot]
com>
Follow me on Twitter
Last edited 06/18/2013
Since ISPConfig 3.0.5, it is possible to use multiple PHP versions on one server and select the optimal PHP version for a website. If you have some very old websites on your server, they might not work with PHP5, but only with PHP4. This tutorial shows how to build PHP 4.4.9 as a FastCGI version for use with Apache2 on a Debian Wheezy server. This PHP version can be used together with the default PHP (installed through apt) in ISPConfig.
I do not issue any guarantee that this will work for you!
PHP-FPM is not available for PHP4, therefore I just describe how to build a FastCGI version of PHP4. FastCGI is available only for Apache servers, therefore you cannot use it with nginx..
2 Building PHP 4.4.9 (FastCGI)
Install the prerequisites for building from source code:
apt-get install build-essential
PHP 4.4.9 will not compile with modern OpenSSL versions, therefore we need to install an older OpenSSL version (0.9.8x) first:
cd /tmp
wget http://www.openssl.org/source/openssl-0.9.8x.tar.gz
tar xvfz openssl-0.9.8x.tar.gz
cd openssl-0.9.8x
./config âprefix=/usr/local/openssl-0.9.8
make
make install
Download and extract PHP 4.4.9:
mkdir /opt/phpfcgi-4.4.9
mkdir /usr/local/src/php4-build
cd /usr/local/src/php4-build
wget http://de.php.net/get/php-4.4.9.tar.bz2/from/this/mirror -O php-4.4.9.tar.bz2
tar jxf php-4.4.9.tar.bz2
Create some necessary symlinks:
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient.so
mkdir /usr/kerberos
ln -s /usr/lib/x86_64-linux-gnu /usr/kerberos/lib
Next we must disable the functions mysql_drop_db and mysql_create_db because otherwise you will get these errors when you try to build PHP 4.4.9:
error: undefined reference to âmysql_drop_dbâ
error: undefined reference to âmysql_create_dbâ
Open /usr/local/src/php4-build/php-4.4.9/ext/mysql/php_mysql.câŚ
vi /usr/local/src/php4-build/php-4.4.9/ext/mysql/php_mysql.c
⌠and go to line 1131. From there on, comment out both functions:
[...] /*PHP_FUNCTION(mysql_create_db) { zval **db, **mysql_link; int id; php_mysql_conn *mysql; switch(ZEND_NUM_ARGS()) { case 1: if (zend_get_parameters_ex(1, &db)==FAILURE) { RETURN_FALSE; } id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU); CHECK_LINK(id); break; case 2: if (zend_get_parameters_ex(2, &db, &mysql_link)==FAILURE) { RETURN_FALSE; } id = -1; break; default: WRONG_PARAM_COUNT; break; } php_error_docref(NULL TSRMLS_CC, E_NOTICE, "This function is deprecated, please use mysql_query() to issue a SQL CREATE DATABASE statement instead."); ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink); PHPMY_UNBUFFERED_QUERY_CHECK(); convert_to_string_ex(db); if (mysql_create_db(&mysql->conn, Z_STRVAL_PP(db))==0) { RETURN_TRUE; } else { RETURN_FALSE; } }*/ /* }}} */ /* {{{ proto bool mysql_drop_db(string database_name [, int link_identifier]) Drops (delete) a MySQL database */ /*PHP_FUNCTION(mysql_drop_db) { zval **db, **mysql_link; int id; php_mysql_conn *mysql; switch(ZEND_NUM_ARGS()) { case 1: if (zend_get_parameters_ex(1, &db)==FAILURE) { RETURN_FALSE; } id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU); CHECK_LINK(id); break; case 2: if (zend_get_parameters_ex(2, &db, &mysql_link)==FAILURE) { RETURN_FALSE; } id = -1; break; default: WRONG_PARAM_COUNT; break; } php_error_docref(NULL TSRMLS_CC, E_NOTICE, "This function is deprecated, please use mysql_query() to issue a SQL DROP DATABASE statement instead."); ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink); convert_to_string_ex(db); if (mysql_drop_db(&mysql->conn, Z_STRVAL_PP(db))==0) { RETURN_TRUE; } else { RETURN_FALSE; } }*/ /* }}} */ [...]
Install the prerequisites for building PHP5 (in our case this also covers the prerequisites for building PHP4):
Configure and build PHP 4.4.9 as follows (you can adjust the ./configure command to your needs, take a look at
to see all available options; if you use a different ./configure command, it is possible that additional libraries are required, or the build process will fail):
./configure \
âprefix=/opt/phpfcgi-4.4.9 \
âwith-pdo-pgsql \
â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 \
âwith-mhash \
âenable-zip \
âwith-pcre-regex \
âwith-mysql=/usr \
âwith-mysql-sock=/var/run/mysqld/mysqld.sock \
âwith-jpeg-dir=/usr \
âwith-png-dir=/usr \
âenable-gd-native-ttf \
âwith-openssl=/usr/local/openssl-0.9.8 \
âwith-openssl-dir=/usr/local/openssl-0.9.8 \
âwith-libdir=/lib/x86_64-linux-gnu \
âenable-ftp \
âwith-imap \
âwith-imap-ssl \
âwith-kerberos \
âwith-gettext \
âwith-expat-dir=/usr \
âenable-fastcgi
The last switch (âenable-fastcgi) makes sure this PHP version will work with FastCGI.
Copy php.ini to the correct location:
cp /usr/local/src/php4-build/php-4.4.9/php.ini-recommended /opt/phpfcgi-4.4.9/lib/php.ini
Thatâs it â we will now add the APC module to our PHP 4.4.9 installation:
cd /tmp
wget http://pecl.php.net/get/APC-3.0.19.tgz
tar xvfz APC-3.0.19.tgz
cd APC-3.0.19
/opt/phpfcgi-4.4.9/bin/phpize
./configure âenable-apc âenable-apc-mmap âwith-php-config=/opt/phpfcgi-4.4.9/bin/php-config
make
make install
Afterwards, open /opt/phpfcgi-4.4.9/lib/php.iniâŚ
vi /opt/phpfcgi-4.4.9/lib/php.ini
⌠and set extension_dir = â/opt/phpfcgi-4.4.9/lib/php/extensions/no-debug-non-zts-20020429âł and add the line extension=apc.so at the end of the file (you can also configure some additional APC settings):
[...] extension_dir = "/opt/phpfcgi-4.4.9/lib/php/extensions/no-debug-non-zts-20020429" [...] extension=apc.so apc.enabled=1 apc.shm_segments=1 apc.shm_size=512 apc.ttl=0 apc.user_ttl=600 apc.gc_ttl=600 apc.enable_cli=1 apc.mmap_file_mask=/tmp/apc.XXXXXX ;apc.mmap_file_mask=/dev/zero ;apc.shm_segments = 5
In ISPConfig 3.0.5, you can configure the new PHP version under System > Additional PHP Versions. On the Name tab, you just fill in a name for the PHP version (e.g. PHP 4.4.9) â this PHP version will be listed under this name in the website settings in ISPConfig:
(JavaScript must be enabled in your browser to view the large image as an image overlay.)
Go to the FastCGI Settings tab (the PHP-FPM Settings tab can be left empty) and fill out the fields as follows:
(JavaScript must be enabled in your browser to view the large image as an image overlay.)
If everything is working as expected, you can now choose PHP 4.4.9 for a website in ISPConfig. You can check the PHP version of a website by creating a PHP file with the phpinfo(); function in it and calling that file in your browser:
(JavaScript must be enabled in your browser to view the large image as an image overlay.)
Falko Timme is the owner of Timme Hosting (ultra-fast nginx web hosting). He is the lead maintainer of HowtoForge (since 2005) and one of the core developers of ISPConfig (since 2000). He has also contributed to the OâReilly book âLinux System Administrationâ.
Check out the original source here.