Tiro monedas al aire, pero hasta ahora nunca las pude agarrar.

Quería tener PHP7 en mi Debian Jessie, así que manos a la obra. Entramos a la terminal y tecleamos lo siguiente:
sudo aptitude update && sudo aptitude install build-essential nano 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
sudo mkdir -p /opt/php-7.0.0
sudo mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
sudo wget -c http://de1.php.net/get/php-7.0.0.tar.bz2/from/this/mirror -O php-7.0.0.tar.bz2
sudo tar jxf php-7.0.0.tar.bz2
cd php-7.0.0/
sudo ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
./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
sudo make install
sudo cp /usr/local/src/php5-build/php-7.0.0/php.ini-production /opt/php-7.0.0/lib/php.ini
sudo cp /opt/php-7.0.0/etc/php-fpm.conf.default /opt/php-7.0.0/etc/php-fpm.conf
sudo cp /opt/php-7.0.0/etc/php-fpm.d/www.conf.default /opt/php-7.0.0/etc/php-fpm.d/www.conf
sudo nano /opt/php-7.0.0/etc/php-fpm.conf

Sacamos el comentario donde dice:
[...]
pid = run/php-fpm.pid
[...]

Guardamos el archivo (control + o) y luego cerramos el editor (control + x). Volvemos a entrar a la terminal y tecleamos lo siguiente:
sudo nano /opt/php-7.0.0/etc/php-fpm.d/www.conf

Sacamos el comentario donde dice:
[...]
listen = 127.0.0.1:8999
[...]

OBS:

  • Pueden usar otro que puerto que tienen disponible.

Guardamos el archivo (control + o) y luego cerramos el editor (control + x).
Ahora creamos un script. Volvemos a entrar a la terminal y tecleamos lo siguiente:
sudo nano /etc/init.d/php-7.0.0-fpm

Agregamos:
#! /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

Guardamos el archivo (control + o) y luego cerramos el editor (control + x). Volvemos a entrar a la terminal y tecleamos lo siguiente:
sudo chmod 755 /etc/init.d/php-7.0.0-fpm
sudo insserv php-7.0.0-fpm
sudo nano /lib/systemd/system/php-7.0.0-fpm.service

Agregamos:
[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

Guardamos el archivo (control + o) y luego cerramos el editor (control + x). Volvemos a entrar a la terminal y tecleamos lo siguiente:
sudo systemctl daemon-reload
sudo /etc/init.d/php-7.0.0-fpm start

Sale por pantalla lo siguiente:
Starting php-fpm  done

Volvemos a entrar a la terminal y tecleamos lo siguiente:
sudo nano /opt/php-7.0.0/lib/php.ini

Agregamos al final del archivo:
zend_extension=opcache.so

Guardamos el archivo (control + o) y luego cerramos el editor (control + x). Volvemos a entrar a la terminal y tecleamos lo siguiente:
cd /opt/php-7.0.0/bin
./php --version

Sale lo siguiente:
PHP 7.0.0 (cli) (built: Dec  3 2015 23:09:43) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Fuente: HowtoForge


Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *