How To Use Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (Ubuntu 12.04 LTS) - Page 4

5 Building PHP 5.4.12 (FastCGI)

Download and extract PHP 5.4.12:

mkdir /opt/phpfcgi-5.4.12
mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
wget http://de.php.net/get/php-5.4.12.tar.bz2/from/this/mirror -O php-5.4.12.tar.bz2
tar jxf php-5.4.12.tar.bz2

cd php-5.4.12/

Install the prerequisites for building PHP5:

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

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

(The last command is needed if you build PHP with --with-imap, because otherwise ./configure will stop with the following error:

checking for crypt in -lcrypt... yes
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
root@server1:/usr/local/src/php5-build/php-5.4.12#

)

Configure and build PHP 5.4.12 as follows (you can adjust the ./configure command to your needs, take a look at

./configure --help

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-5.4.12 \
--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 \
--with-pdo-mysql \
--with-mysqli \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-gd-native-ttf \
--with-openssl \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-libdir=/lib/x86_64-linux-gnu \
--enable-ftp \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-gettext \
--enable-cgi

The last switch (--enable-cgi) makes sure this PHP version will work with FastCGI.

make
make install

Copy php.ini to the correct location:

cp /usr/local/src/php5-build/php-5.4.12/php.ini-production /opt/phpfcgi-5.4.12/lib/php.ini

That's it - if you like, you can now install some additional modules like APC, memcache, memcached, and ioncube.

The APC, memcache, and memcached modules can be installed through PEAR which we must install and initialize first:

apt-get -y install php-pear

cd /opt/phpfcgi-5.4.12/etc

pecl -C ./pear.conf update-channels

APC can now be installed as follows:

pecl -C ./pear.conf install apc

Accept all default values. Afterwards, open /opt/phpfcgi-5.4.12/lib/php.ini...

vi /opt/phpfcgi-5.4.12/lib/php.ini

... and add the line extension=apc.so at the end of the file (you can also configure some additional APC settings):

[...]
extension=apc.so
apc.enabled=1
apc.shm_size=128M
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

The memcache extension can be installed as follows:

pecl -C ./pear.conf install memcache

Open /opt/phpfcgi-5.4.12/lib/php.ini...

vi /opt/phpfcgi-5.4.12/lib/php.ini

... and add the line extension=memcache.so at the end of the file:

[...]
extension=memcache.so

The memcached extension can be installed as follows:

apt-get install libmemcached-dev

ln -s /usr/include/libmemcached /usr/include/libmemcached-1.0

pecl -C ./pear.conf install memcached

Open /opt/phpfcgi-5.4.12/lib/php.ini...

vi /opt/phpfcgi-5.4.12/lib/php.ini

... and add the line extension=memcached.so at the end of the file:

[...]
extension=memcached.so

The ionCube Loader can be installed as follows:

cd /tmp

Next download and unpack the correct ionCube Loader package for your architecture (x86_64 or x86).

For x86_64:

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

For x86:

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Proceed as follows:

cp ioncube/ioncube_loader_lin_5.4.so /opt/phpfcgi-5.4.12/lib/php/extensions/no-debug-non-zts-20100525/ioncube.so
vi /opt/phpfcgi-5.4.12/lib/php.ini

Add the line zend_extension = /opt/phpfcgi-5.4.12/lib/php/extensions/no-debug-non-zts-20100525/ioncube.so right at the beginning of the file (before the [PHP] line):

zend_extension = /opt/phpfcgi-5.4.12/lib/php/extensions/no-debug-non-zts-20100525/ioncube.so
[PHP]
[...]

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 5.4.12) - this PHP version will be listed under this name in the website settings in ISPConfig:

Go to the FastCGI Settings tab (the PHP-FPM Settings tab can be left empty) and fill out the fields as follows:

 

6 Links

 

About The Author

Falko Timme is the owner of nginx WebhostingTimme 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".

Share this page:

14 Comment(s)

Add comment

Comments

From: junkri at: 2013-03-08 13:46:10

On debian 6(squeeze), you shoud use --with-libdir=/lib64 instead of --with-libdir=/lib/x86_64-linux-gnu
 
without that, you'll get the error of imap library mentioned above.

From: suther at: 2013-05-16 15:51:29

For i386/i686 system you have to remove the parameter: --with-libdir=/lib/x86_64-linux-gnu.

 Otherwise, you got the imap-error described for x64 system above!

From: junkri at: 2013-03-08 17:11:48

if the php_fpm can't handle the new versions of php, make sure that you enabled fastcgi:

apt-get install libapache2-mod-fastcgi
a2enmod fastcgi
/etc/init.d/apache2 restart

From: Anonymous at: 2013-04-01 05:45:00

#2

I GET TO: ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

 ln: failed to create symbolic link `/usr/lib/x86_64-linux-gnu/libc-client.a': No such file or directory

ANY HELP????

From: Pavel at: 2013-07-30 19:58:39

Is possible add to this tutorial php version 5.2.x? For example 5.2.6, or 5.2.17. Probably this is version, what is required for old joomla 1.5.x.

 Thanks

From: Anonymous at: 2013-10-10 16:06:26

I get to 

 cp /opt/php-5.3.22/etc/php-fpm.conf.default /opt/php-5.3.22/etc/php-fpm.conf 

 and i get cp:cannot stat `/opt/php-5.3.22/etc/php-fpm.conf.default': no such file or directory

 Can someone please explain me why i get it and how to fix it?

From: iNeard at: 2013-11-18 20:53:31

Only for x64!
To correct the libc-client-Error:

ln -s /usr/lib/libc-client.a /usr/lib64/


To correct the libmysqlclient-Error:

ln -s /usr/lib/libmysqlclient.a /usr/lib64/


After that, the ./configure-Command:

..
--with-libdir=/lib64
..

thx

From: at: 2014-02-11 10:49:01

I have installed Ubuntu 12.04 LTS and ISPconfig 3 the last stable on 32-bit pc

1st error

When I put command

 

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

 

I get result: No such file or directory

2nd error

When I put command

cp /usr/local/src/php5-build/php-5.3.22/php.ini-production /opt/php-5.3.22/lib/php.ini

 

I get result: No such file or directory
Directory lib doesn't exist

can somebody resolve this problems?
Thanks

From: Anonymous at: 2014-10-14 08:46:17

i get an error using:

wget http://de.php.net/get/php-5.3.22.tar.bz2/from/this/mirror -O php-5.3.22.tar.bz2

returns:

Connecting to de.php.net (de.php.net)|212.124.37.9|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-10-14 04:33:34 ERROR 404: Not Found.

Was the download location changed? Anyone else experienced this issue?

Any updated links to download older php versions properly?

 

Thanks in advanced!

From: Horst at: 2014-03-04 04:22:21

Hallo Team

ISPconfig 3 zweite PHP Version wird nicht übernommen, intern keine -zuweisung zur Domain erfolgt.

Bei Prüfung wird stets die Standard php-5.4 Version gefunden, sollte aber php-5.3.28 sein.

Korrekt nach Anleitung installiert phad /opt/....

Warum übernimmt ISPconfig 3 nicht diese -zuweisung.

danke für Rückantwort

From: Jürgen at: 2014-11-06 15:05:45

Thanks for a wonderful tutorial (again).  I downloaded php 5.4.34 instead; all worked immediately.

From: johnymas at: 2015-03-14 12:53:37

Hello.

On Ubuntu 14.04, after the fix for "libc-client.a", you also have to do the following :

ln -s /usr/include/freetype2 /usr/include/freetype2/freetype

Otherwise ./configure will failed with a "freetype.h not found" error.

by Cédric.

From: dmgeurts at: 2015-04-07 20:04:02

Anyone get this error? I'm seeing some references to changing the logrotate entry. Can this be done without affecting the native php version? (Ubuntu 14.04)

/etc/cron.daily/logrotate: initctl: invalid command: reopen-logs Try `initctl --help' for more information. invoke-rc.d: initscript php5-fpm, action "reopen-logs" failed. error: error running non-shared postrotate script for /var/log/php5-fpm.log of '/var/log/php5-fpm.log ' run-parts: /etc/cron.daily/logrotate exited with return code 1

From: ezero at: 2015-04-11 23:51:22

If someone still having problems with configuring I would recommend making this change. I did it on my ubuntu 14.10 server.

Go to /usr/ directory

 

[code]cd /usr/[/code]

 

Now create a symlink to lib directory called lib64

[code]ln -s /usr/lib lib64[/code]

 

Now configure using 

 

[code]

./configure \

--prefix=/opt/php-5.3.22 \

--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 \

--with-pdo-mysql \

--with-mysqli \

--with-jpeg-dir=/usr \

--with-png-dir=/usr \

--enable-gd-native-ttf \

--with-openssl \

--with-fpm-user=www-data \

--with-fpm-group=www-data \

--with-libdir=/lib64 \

--enable-ftp \

--with-imap \

--with-imap-ssl \

--with-openssl  \

--with-kerberos \

--with-gettext \

--enable-fpm

 

[/code]