Installation de PHP 7 RC1 sur Debian 8

1/52/53/54/55/5 (2 votes, moyenne: 3,00 sur 5)
Loading...
I

Attention, cet article a plus d'une année d'ancienneté. Il est possible que les informations présentées ne soient plus à jour, spécialement dans le cadre d'un article technique.


Bonjour à tous,

PHP 7 approche de plus en plus avec sa première release candidate (RC).

Il est maintenant temps de commencer à tester ces infrastructures pour voir les problèmes de compatibilité encore présent et éliminer tout cela pour une migration en douceur lorsque la version finale arrivera.

De mon côté, j’ai testé tout cela sur le serveur qui héberge The Abyss Project et pour l’instant, rien n’est compatible.

Erreurs 500 en boucle sur wordpress et 502 sur Piwik par exemple.

Pour information, je reprends une procédure de Till Brehm qui expliquait comment installer une version bêta de PHP 7.

Téléchargement et compilation de php 7 RC1 :

Dans un premier temps, vous allez installer tous les logiciels nécessaires à la compilation de PHP :

apt-get update && apt-get install build-essential libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg 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 && ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

Maintenant, téléchargez PHP 7 RC1, décompressez-la et placez-vous dans le dossier des sources :

mkdir -p /opt/php-7.0.0
mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
wget https://downloads.php.net/~ab/php-7.0.0RC1.tar.gz
tar xvzf php-7.0.0RC1.tar.gz
cd php-7.0.0RC1/

Ensuite, compilez la bestiole avec ces commandes :

./configure --prefix=/opt/php-7.0.0 --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-mysqli --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 --with-xmlrpc --with-xsl --enable-opcache --enable-fpm
make
make install

Copiez les fichiers de configuration de PHP dans leurs emplacements finaux :

cp /usr/local/src/php5-build/php-7.0.0beta1/php.ini-production /opt/php-7.0.0/lib/php.ini
cp /opt/php-7.0.0/etc/php-fpm.conf.default /opt/php-7.0.0/etc/php-fpm.conf
cp /opt/php-7.0.0/etc/php-fpm.d/www.conf.default /opt/php-7.0.0/etc/php-fpm.d/www.conf

Ensuite, dé-commentez la ligne PID :

nano /opt/php-7.0.0/etc/php-fpm.conf

[…]
pid = run/php-fpm.pid
[…]

Pour finir, changez le port d’écoute de php 7 si vous avez une autre version installée :

nano /opt/php-7.0.0/etc/php-fpm.d/www.conf

[…]
listen = 127.0.0.1:8999
[…]

Création du script de démarrage et de l’unité systemd pour FPM :

On va créer un init basique de démarrage pour le module FPM :

nano /etc/init.d/php-7.0.0-fpm

Copiez ceci dans le fichier et sauvegardez :

#! /bin/sh
### BEGIN INIT INFO
# Provides:          php-7.0.0-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-7.0.0-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-7.0.0/sbin/php-fpm
php_fpm_CONF=/opt/php-7.0.0/etc/php-fpm.conf
php_fpm_PID=/opt/php-7.0.0/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

Rendez le fichier exécutable et créez le lien de démarrage :

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

Maintenant, créez l’unité systemd :

nano /lib/systemd/system/php-7.0.0-fpm.service

Copiez ceci dans le fichier et sauvegardez :

[Unit]
Description=The PHP 7 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php-7.0.0/var/run/php-fpm.pid
ExecStart=/opt/php-7.0.0/sbin/php-fpm --nodaemonize --fpm-config /opt/php-7.0.0/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Rechargez systemd pour prendre en compte la modification :

systemctl daemon-reload

Maintenant, lancez PHP7-FPM avec la commande suivante :

systemctl start php-7.0.0-fpm

Pour activer l’opcache Zend, ouvrez le fichier php.ini :

nano /opt/php-7.0.0/lib/php.ini

Et ajoutez la ligne suivante à la fin :

zend_extension=opcache.so

Intégrer PHP 7 RC1 à ISPConfig 3 :

Connectez-vous sur le panel d’administration de ISPConfig et allez dans Système -> Additional PHP Versions.

php7-ispconfig3-1

Maintenant, mettez php7 en nom et cliquez sur FastCGI Settings :php7-ispconfig3-2

Renseignez les chemins vers les dossiers de PHP 7 demandés :

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

php7-ispconfig3-3

Faites la même chose dans PHP-FPM Settings :

Path to the PHP-FPM init script: /etc/init.d/php-7.0.0-fpm
Path to the php.ini directory: /opt/php-7.0.0/lib
Path to the PHP-FPM pool directory: /opt/php-7.0.0/etc/php-fpm.d

php7-ispconfig3-4

Maintenant, allez sur un de vos sites et modifiez la version de php pour php7 :php7-ispconfig3-5

A propos de l'auteur

Nicolas Simond

Ingénieur Systèmes et Réseaux et guitariste hard rock et metal à mes heures perdues.
Je suis le créateur et l'unique rédacteur d'Abyss Project, c'est ici que je note la plupart de mes procédures et quelques divagations.

Si vous l'article vous a aidé, pensez à me payer un café :)

Subscribe
Notify of
guest

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.

0 Commentaires
Inline Feedbacks
View all comments