SOLUTION: DEBIAN multiple PHP version

Discussion in 'Installation/Configuration' started by styx-tdo, Nov 26, 2013.

  1. styx-tdo

    styx-tdo New Member

    Hi,
    I just wanted to share how to have multiple PHP versions in ISPConfig with Debian

    Solution:
    Code:
    apt-get install makejail 
    apt-get install debootstrap
    chose a directory, e.g. /srv/php
    Code:
    mkdir /srv/php
    cd /srv/php
    debootstrap squeeze .
    chroot .
    vi /etc/apt/sources.list
    Update this to your preferred sources, e.g.
    Code:
    deb http://cdn.debian.net/debian/ sid main non-free contrib
    then, the usual:
    Code:
    apt-get update;apt-get upgrade
    now we are ready to install php-fpm:
    Code:
    apt-get install php-pear php5-adodb php5-cli php5-common php5-fpm php5-gd php5-imap php5-json php5-mcrypt php5-memcache php5-mysqlnd php5-mysqlnd-ms php5-readline php5-sasl php5-xmlrpc php5-xsl
    
    Create www dir:
    Code:
    mkdir -p /var/www
    Now, PHP in the jail is more or less ready. If you want, edit /etc/php5/fpm/php.ini (i added short_tags = on to allow <? instead of <?php ).

    Exit the chroot (ctrl-D or exit)

    This was phase 1.
    In ISPConfig, go to System -> Additional PHP versions; click "Add new PHP version"

    The name is e.g. php 5.5.4
    fastCGI settings: Leave empty
    PHP-FPM settings:
    Path to init script: /etc/init.d/chrooted-fpm
    Path to php.ini: /srv/php/etc/php5/fpm
    Path to pool: /srv/php/etc/php5/fpm/pool.d

    Now, all that is missing is a init script outside the pool.
    edit /etc/init.d/chrooted-fpm
    Code:
    #!/bin/bash
    #
    # Copyright (c) 2013 styx-tdo
    #
    # /etc/init.d/chrooted-fpm
    #
    ### BEGIN INIT INFO
    # Provides:                     chrooted-fpm
    # Required-Start:               $local_fs $remote_fs $network
    # Required-Stop:                $local_fs $remote_fs $network
    # Default-Start:                3 5
    # Default-Stop:                 0 1 2 6
    # Short-Description:            chrooted debian php-fpm
    # Description:                  Start a chrooted debian php-fpm
    ### END INIT INFO
    
    JAIL="/srv/php"
    #always a good idea - these must not be out of sync. If you have /etc and /srv on the same FS, you can also do a hard link.
    for I in passwd group shadow;do
            cp /etc/$I $JAIL/etc/$I
    done
    
    case "$1" in
        start)
            echo "starting chrooted debian system (php-fpm) in $ROOT";
    
            mount -o bind /proc $JAIL/proc
            mount -o bind /var/www $JAIL/var/www
    
            chroot $JAIL /bin/bash << EOF
            /etc/init.d/php5-fpm start
    EOF
            ;;
    
        stop)
            echo "stopping chrooted debian system (php-fpm) in $ROOT";
            chroot $JAIL /bin/bash << EOF
            /etc/init.d/php5-fpm stop
    EOF
            umount $JAIL/proc
            umount $JAIL/var/www
            ;;
    
        *)
            chroot $JAIL /bin/bash << EOF
            /etc/init.d/php5-fpm $1
    EOF
            ;;
    esac
    Install the runlevel scripts:
    Code:
    update-rc.d chrooted-fpm defaults
    and you are done.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. styx-tdo

    styx-tdo New Member

    Hi Till,
    the difference is that above solution actually does not require recompiling and allows updating via Apt instead of re-downloading and re-compiling (which is - in my opinion - a major advantage ;) )
     

Share This Page