HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   How to install multiple versions of php to work with nginx. (http://www.howtoforge.com/forums/showthread.php?t=58788)

pvanthony 20th September 2012 17:59

How to install multiple versions of php to work with nginx.
 
Hi,

Currently using ispconfig 3 with nginx with php 5.3 on CentOS 6.

Now there is a requirement to run php 5.2 together with php 5.3.

Is there a way to do this using yum? If not, what other way can I get this done?

Your advice is greatly appreciated.

P.V.Anthony

falko 21st September 2012 17:40

This is how it works on Ubuntu and Debian:

Code:

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

wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | sudo patch -d php-5.2.17 -p1

cd php-5.2.17/

apt-get build-dep php5

apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev libssl-dev

ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so


./configure \
--prefix=/opt/php-5.2.17 \
--with-pdo-pgsql \
--with-zlib-dir \
--with-freetype-dir \
--enable-fpm \
--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 \
--enable-fastcgi \
--with-pear \
--enable-memcache \
--with-openssl



http://zgadzaj.com/how-to-install-php-53-and-52-together-on-ubuntu-1204

This is due to PHP bug #54736, which could be easily resolved using patch debian_patches_disable_SSLv2_for_openssl_1_0_0.patch attached to that bug report.

Download this patch to your ~/Downloads/php-5.2.17 directory, and execute:

patch -p1 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch.patch



make
make install


cp /usr/local/src/php5-build/php-5.2.17/php.ini-recommended /opt/php-5.2.17/lib/php.ini




mkdir /opt/php-5.2.17/etc/pool.d
mkdir -p /opt/php-5.2.17/var/run


vi /etc/init.d/php-5.2.17-fpm
=========================
#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-5.2.17-fpm
# Required-Start:    $all
# Required-Stop:    $all
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-5.2.17-fpm
# Description:      starts the PHP FastCGI Process Manager daemon
### END INIT INFO

php_fpm_BIN=/opt/php-5.2.17/sbin/php-fpm
php_fpm_CONF=/opt/php-5.2.17/etc/php-fpm.conf
php_fpm_PID=/opt/php-5.2.17/logs/php-fpm.pid

php_opts="--fpm-config $php_fpm_CONF"


wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;

                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac

                echo -n .
                try=`expr $try + 1`
                sleep 1

        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "

                $php_fpm_BIN start

                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi

                wait_for_pid created $php_fpm_PID

                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;

        stop)
                echo -n "Gracefully shutting down php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -QUIT `cat $php_fpm_PID`

                wait_for_pid removed $php_fpm_PID

                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                      echo " done"
                fi
        ;;

        force-quit)
                echo -n "Terminating php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -TERM `cat $php_fpm_PID`

                wait_for_pid removed $php_fpm_PID

                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;

        restart)
                $0 stop
                $0 start
        ;;

        reload)

                echo -n "Reload service php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -USR2 `cat $php_fpm_PID`

                echo " done"
        ;;

        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;

esac



chmod 755 /etc/init.d/php-5.2.17-fpm
insserv php-5.2.17-fpm

/etc/init.d/php-5.2.17-fpm start


pvanthony 2nd October 2012 07:57

Thank you very much for sharing this.

P.V.Anthony

coozila 25th January 2013 04:36

fpm start error
 
[root@www php-5.2.17]# /etc/init.d/php-5.2.17-fpm start
Starting php-fpm Starting php_fpm Jan 25 04:26:37.161305 [ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
................................... failed
failed

falko 25th January 2013 15:48

You must specify a user and group for the default pool.

harkman 2nd July 2013 12:10

Hello.

I tried to install php 5.2.17 alonside default php 5.4 on a Nginx webserver

My problem now is, that the php-fpm pools in php 5.2 are not read. I found that the configuration files in 5.2 are in XML while 5.3 and up use ini-format.

Is there any way to tell ispConfig to create pool configs in XML?

I also tried to install 5.2 in fastcgi mode, but unfortunately latest ispconfig version has dropped fastcgi support for nginx.

Can someone give some advice hot to solve this?

Regards, Jürgen


All times are GMT +2. The time now is 02:47.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.