Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ad-inserter domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cookie-law-info domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114
Installare PHP 7 su Ubuntu LTS 14.04 - Blog WebEats

Un breve tutorial da seguire per installare PHP 7 su Ubuntu LTS 14.04 (versione corrente PHP 7.0.2) ed usarlo con PHP-FPM e FastCGIPHP 7 su Ubuntu LTS 14.04

Ricordiamo che PHP-FPM è compatibile sia per nginx che Apache, mentre FastCGI solo con Apache.

Creiamo la directory dove andremo a lavorare e scarichiamo i sorgenti di PHP 7 da github

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

Installiamo un pò di pacchetti necessari alla compilazione

apt-get install build-essential nano
apt-get install libfcgi-dev libfcgi0ldbl libjpeg-turbo8-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

In caso di compilazione con –with-imap, è necessario eseguire questo comando

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

Bene ora compiliamo con

./configure --prefix=/opt/php-7.0.2 --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/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

Copiamo i file php.ini e php-fpm.conf nelle directory giuste

cp /usr/local/src/php5-build/php-7.0.2/php.ini-production /opt/php-7.0.2/lib/php.ini

cp /opt/php-7.0.2/etc/php-fpm.conf.default /opt/php-7.0.2/etc/php-fpm.conf
cp /opt/php-7.0.2/etc/php-fpm.d/www.conf.default /opt/php-7.0.2/etc/php-fpm.d/www.conf

Apriamo il file /opt/php-7.0.2/etc/php-fpm.conf ed eliminiamo il ; sulla linea del pid

pico /opt/php-7.0.2/etc/php-fpm.conf

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

Ora dobbiamo modificare la porta da 9000 (in uso nella versione standard presente in Ubuntu) a 8999

pico /opt/php-7.0.2/etc/php-fpm.d/www.conf

[...]
listen = 127.0.0.1:8999
[...]

Ora è necessario creare gli script di init

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

rendiamo eseguibili lo script

chmod 755 /etc/init.d/php-7.0.2-fpm
update-rc.d php-7.0.2-fpm defaults

creiamo il servizio dedicato a PHP 7

pico /lib/systemd/system/php-7.0.2-fpm.service
[Unit]
Description=The PHP 7 FastCGI Process Manager
After=network.target

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

[Install]
WantedBy=multi-user.target

Abilitiamo il servizio e ricarichiamo systemd (comandi non necessari sotto Ubuntu)
systemctl enable php-7.0.2-fpm.service
systemctl daemon-reload

ora avviamo PHP 7 FPM con

service php-7.0.2-fpm start

o

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

o sui server che usano systemd

systemctl start php-7.0.2-fpm.service

Ora vediamo come aggiungere Zend OPCache. Editiamo il file /opt/php-7.0.2/lib/php.ini

pico /opt/php-7.0.2/lib/php.ini

e alla fine del file aggiugiamo
[...]
zend_extension=opcache.so

Per verificare il corretto funzionamento di PHP 7 eseguiamo il seguente comando

cd /opt/php-7.0.2/bin
./php --version

Ricordiamo che Memcache e APCu non possono essere ancora installati su PHP 7, quindi per il momento evitiamo l’installazione.

Guida basata su HowToForge