PHP Installation · 5 min read · Nov 01, 2025
Come installare PHP 7 (PHP-FPM & FastCGI) per ISPConfig 3 su Debian 8 (Jessie)
La prima Beta di PHP 7 è disponibile per il download ora, PHP 7 è fino a 2 volte più veloce di php 5.6 e 14 volte più veloce di php 5.0 secondo le note di rilascio. La nuova versione di PHP non è 100% compatibile con PHP 5.x poiché alcune API deprecate sono state rimosse, quindi è una buona idea iniziare a testare i tuoi siti web per la compatibilità con questo nuovo rilascio. Questo può essere fatto facilmente e senza influenzare tutti i siti sul tuo server utilizzando la funzione multi versione PHP in ISPConfig 3. La versione PHP può essere selezionata nelle impostazioni del sito web di ISPConfig 3 per ciascun sito individualmente. Questa funzione funziona con PHP-FPM e FastCGI. Questo tutorial mostra come costruire il nuovo PHP 7 (Beta) come versione PHP-FPM e FastCGI su un server Debian Jessie. Queste build di PHP 7 includono Zend OPcache.
Nota preliminare
Installerò PHP 7 che è attualmente in Beta al momento della scrittura. Si prega di notare che PHP-FPM può essere utilizzato sia su server Apache che nginx, mentre FastCGI è disponibile solo per server Apache.
Con le versioni PHP più vecchie, PHP-FPM e FastCGI erano stati mutuamente esclusivi in modo che un binario fpm e FastCGI fosse stato costruito separatamente. Con PHP 7, entrambi i binari possono essere costruiti insieme, quindi ora dovremo fare solo una build PHP.
Compilare PHP 7 con PHP-FPM e Fastcgi
Scarica e estrai PHP 7:
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.0beta1.tar.bz2 -O php-7.0.0.tar.bz2
tar jxf php-7.0.0.tar.bz2cd php-7.0.0beta1/Installa i prerequisiti per costruire PHP 7 e l’editor nano che userò per modificare i file di configurazione:
apt-get install build-essential nanoapt-get install 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-devln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a(L’ultimo comando è necessario se si costruisce PHP con –with-imap, perché altrimenti ./configure si fermerà con il seguente errore:
checking for crypt in -lcrypt... yes
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
root@server1:/usr/local/src/php5-build/php-7.0.0#)
Configura e costruisci PHP 7.0.0 come segue (puoi adattare il comando ./configure alle tue esigenze, dai un’occhiata a
./configure --helpper vedere tutte le opzioni disponibili; se usi un comando ./configure diverso, è possibile che siano necessarie librerie aggiuntive, o il processo di build fallirà):
./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-fpmL’ultimo switch ( –enable-fpm) assicura che questa versione di PHP funzioni con PHP-FPM.
make
make installCopia php.ini e php-fpm.conf nelle posizioni corrette:
cp /usr/local/src/php5-build/php-7.0.0beta1/php.ini-production /opt/php-7.0.0/lib/php.inicp /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.confApri /opt/php-7.0.0/etc/php-fpm.conf e modifica la seguente impostazione (rimuovi il # davanti alla riga pid):
nano /opt/php-7.0.0/etc/php-fpm.conf[...]
pid = run/php-fpm.pid
[...] Quindi apri /opt/php-7.0.0/etc/php-fpm.conf e modifica la riga listen, devi usare una porta non utilizzata (ad es. 8999; la porta 9000 potrebbe essere già in uso dal PHP-FPM predefinito di Debian):
nano /opt/php-7.0.0/etc/php-fpm.d/www.conf[...]
listen = 127.0.0.1:8999
[...] Debian supporta Systemd così come gli script di init tradizionali. Prima creerò uno script di init per il servizio php-fpm e poi creerò un’unità systemd.
Prima crea uno script di init per PHP-FPM:
nano /etc/init.d/php-7.0.0-fpm#! /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
;;
esacRendi lo script di init eseguibile e crea i collegamenti di avvio del sistema:
chmod 755 /etc/init.d/php-7.0.0-fpm
insserv php-7.0.0-fpmE ora crea il file di unità systemd
nano /lib/systemd/system/php-7.0.0-fpm.servicecon il seguente contenuto:
[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.targetE ricarica systemd:
systemctl daemon-reloadInfine avvia PHP-FPM.
Per i sistemi con sistema di init tradizionale, esegui:
/etc/init.d/php-7.0.0-fpm startIl risultato dovrebbe essere:
/etc/init.d/php-7.0.0-fpm start
Starting php-fpm doneSu server che utilizzano systemd, usa questo comando invece:
systemctl start php-7.0.0-fpm.servicePer abilitare Zend OPcache, apri /opt/php-7.0.0/lib/php.ini…
nano /opt/php-7.0.0/lib/php.ini… e aggiungi la seguente riga alla fine:
[...]
zend_extension=opcache.soL’estensione memcache e APCu non può essere installata su PHP 7 ancora, quindi salterò la loro installazione per ora. Aggiornerò il tutorial più tardi quando le estensioni pecl saranno compatibili con PHP 7.
Abilitare PHP 7 in ISPConfig
In ISPConfig 3, puoi configurare la nuova versione PHP sotto Sistema > Versioni PHP aggiuntive. Nella scheda Nome, devi solo compilare un nome per la versione PHP (ad es. PHP 7.0.0) - questa versione PHP sarà elencata sotto questo nome nelle impostazioni del sito web in ISPConfig:

Vai alla scheda Impostazioni FastCGI e compila i campi come segue:
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
Poi vai alla scheda Impostazioni PHP-FPM e compila i campi come segue:
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 
4 Link
- PHP: http://www.php.net/
- ISPConfig: http://www.ispconfig.org/
- Debian: http://www.debian.org/
Ricevi i nuovi post nella tua casella di posta.
Nessuno spam. Disiscriviti in qualsiasi momento.