upgrade php for ispconfig 3.0.5.4p8

Discussion in 'General' started by saco721, Mar 14, 2016.

  1. saco721

    saco721 Member

    Hi,
    I have multiserver setup on debian squeeze with ispconfig 3.0.5.4p8 with php PHP 5.3.3-7, and need to upgrade php, what is the easiest and safest method to do this?

    thank you for your time!.
     
  2. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    The easy way is using 3rd party repositories like https://www.dotdeb.org/ - however they tend to support only the latest stable release AND some customers did notice issues from time to time ( segfaults and other funky stuff ) so I wouldn't say it's a safe method.

    You probably want / need to compile PHP and add it as additional version to your ISPConfig. There are some howtos here to do that.
     
  3. saco721

    saco721 Member

    Hi ztk.me,

    thanks for your reply, but where are the howtos for debian squeeze as I can only find one for ubuntu and debian wheezy.
     
    Last edited: Mar 14, 2016
  4. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    They should not differ much, maybe some dependency versions are a bit older. I'd try to use the wheezy howto.
     
  5. saco721

    saco721 Member

    thank you for your time!
     
  6. florian030

    florian030 Well-Known Member HowtoForge Supporter

    Instead of updating the PHP-Version, bette upgrade the server to wheezy or jessie. You won`t receive any updates for squeezy any more. Even the lts-support was dropped a few weeks ago.
     
  7. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    Even this works, Debian 6 does not receive further support so if you compile software or anything else, you're stuck with old software, for example old and possible vulnerable openssl implementation.
    So basically there's a lot to do, but I don't know what environment you're at and maybe you have good reasons to run with old debian ....

    I needed to split this to two posts due to limited post message size

    Compile PHP 7 on Debian 6

    /etc/apt/sources.list
    Code:
    deb http://archive.debian.org/debian/ squeeze main non-free contrib
    deb-src http://archive.debian.org/debian/ squeeze main non-free contrib
    
    deb     http://security.debian.org/  squeeze/updates  main contrib non-free
    deb-src http://security.debian.org/  squeeze/updates  main contrib non-free
    
    Code:
    apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-dev libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev build-essential
    
    Prepare folders and build dir.
    Code:
    mkdir /usr/local/src/php7-build
    cd /usr/local/src/php7-build
    wget http://de1.php.net/get/php-7.0.4.tar.bz2/from/this/mirror -O php-7.0.4.tar.bz2
    tar jxf php-7.0.4.tar.bz2
    cd php-7.0.4
    
    Let's run a simple ./configure, check ./configure --help for available options if you want to customize it.
    Code:
    ./configure --prefix=/opt/php-7.0.4 --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 --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --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 --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm
    
    make install
    Code:
    make
    make install
    
    Copy php.ini and php-fpm.conf to the correct locations:
    Code:
    cp /usr/local/src/php7-build/php-7.0.4/php.ini-production /opt/php-7.0.4/lib/php.ini
    cp /opt/php-7.0.4/etc/php-fpm.conf.default /opt/php-7.0.4/etc/php-fpm.conf
    cp /opt/php-7.0.4/etc/php-fpm.d/www.conf.default /opt/php-7.0.4/etc/php-fpm.d/www.conf
    
    Making sure we get a PID
    Modify /opt/php-7.0.4/etc/php-fpm.conf and uncomment

    Code:
    pid = run/php-fpm.pid
    
    We need one active php-fpm process or service won't start - leading to issues when switching PHP versions.
    Modify /opt/php-7.0.4/etc/php-fpm.d/www.conf

    Code:
    listen = 127.0.0.1:8974 ; choose an unused port
    

    create init-script /etc/init.d/php-7.0.4-fpm
    Code:
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:          php-7.0.4-fpm
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts php-7.0.4-fpm
    # Description:       starts the PHP FastCGI Process Manager daemon
    ### END INIT INFO
    php_fpm_BIN=/opt/php-7.0.4/sbin/php-fpm
    php_fpm_CONF=/opt/php-7.0.4/etc/php-fpm.conf
    php_fpm_PID=/opt/php-7.0.4/var/run/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 $php_opts
                    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
    
    activate it
    Code:
    chmod 755 /etc/init.d/php-7.0.4-fpm
    insserv php-7.0.4-fpm
    
     
  8. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    Customize your /opt/php-7.0.4/lib/php.ini
    Code:
    ; check wether you or your customers need short open tags
    short_open_tag = On
    
    ; check wether you like the outside to know which php version you're running
    expose_php = Off
    
    ; we didn't do a debug build
    report_memleaks = Off
    
    ; UTF-8 rocks, just keep in mind that some websites still use some other charsets and you may want to
    ; overwrite this in ISPConfig website options php-section if you have issues with special charsets
    default_charset = "UTF-8"
    
    ; if you want zend opcode caching go near
    ; Dynamic Extensions ;
    ; section and add
    zend_extension=opcache.so
    
    ; choose a default timzeone for and uncomment date.timezone - right above you see a link
    ; for other timezones to choose from
    date.timezone = "Europe/Berlin"
    
    ; choose mail.log function to track mails from php mail() function, it can help to track
    ; scripts inserted on hacked sites or other abuses
    mail.log = /var/log/phpmail7.log
    
    ; It is disabled by default for maximum compatibility, but enabling it is encouraged.
    ; https://wiki.php.net/rfc/strict_sessions
    session.use_strict_mode = 1
    
    ; if you need more possible session ids, also could make session guessing a few bits harder
    ; check the comments near the configuration options within .ini file
    session.hash_function = 1
    session.hash_bits_per_character = 6
    
    ; if you enabled zend_extension=opcache.so adjust at least the following settings
    opcache.enable=1
    opcache.use_cwd=1 ; make sure it's enabled if you host more than one site using this php version
    opcache.revalidate_path=1
    ; other options as you like
    


    Test your installation. It should output something like
    PHP 7.0.4 (cli) (built: Mar 16 2016 17:28:30) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

    Code:
    /opt/php-7.0.4/bin/php --version
                            


    Enable this version: Log in to your ISPConfig and go to
    System > Additional PHP Versions
    Add new PHP version
    No need to select a customer.
    Set PHP Name to something you want - suggesting: PHP 7

    # if you need PHP by CGI go to FastCGI tab

    Path to the PHP FastCGI binary: /opt/php-7.0.4/bin/php-cgi
    Path to the php.ini directory: /opt/php-7.0.4/lib

    # for PHP-FPM go to PHP-FPM tab

    # just add the filename for systemd usage without .service extension:
    Path to the PHP-FPM init script: /etc/init.d/php-7.0.4-fpm
    Path to the php.ini directory: /opt/php-7.0.4/lib
    Path to the PHP-FPM pool directory: /opt/php-7.0.4/etc/php-fpm.d


    If you need APC usercache compatibility we can add APCu
    Code:
    apt-get install autoconf
    cd /usr/local/src/php7-build
    wget http://pecl.php.net/get/apcu-5.1.3.tgz
    tar xf apcu-5.1.3.tgz
    cd apcu-5.1.3
    /opt/php-7.0.4/bin/phpize
    ./configure --with-php-config=/opt/php-7.0.4/bin/php-config
    make
    make install
                            

    Enable APCu in your /opt/php-7.0.4/lib/php.ini
    Code:
    ; near Dynamic Extensions ; section add
    extension=apcu.so
    apc.enabled=1
    apc.shm_size=32M ; if you are on a virtual server, check your /proc/user_beancounters, shared memory is often limited
    apc.ttl=7200
    apc.enable_cli=0
    
                            

    Check APCu installation
    Code:
    /opt/php-7.0.4/bin/php -i | grep apc
                            


    Start PHP 7.0.4
    Code:
    /etc/init.d/php-7.0.4-fpm start
    
     
    Last edited: Mar 17, 2016

Share This Page