Comments on How to install PHP 7 as PHP-FPM & FastCGI for ISPConfig 3 on Debian 8 (Jessie)
This tutorial shows how to build PHP 7 as a PHP-FPM and a FastCGI version on Debian 8 (Jessie). PHP 7 is up to 2 times faster than PHP 5.6 and 14 times faster than PHP 5.0 according to the release notes.
86 Comment(s)
Comments
Your forgot:
systemctl enable php-7.0.0-fpm.service
Thanks, added it.
i followed all instructions and now i get in wordpress sites
Error establishing a database connectionThe default MySQL socket path from Debian and MySQL differs. You can fix that with:
/bin/ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
or use the updated configure statement from the tutorial and recompile php.
And after this - u cant connect to your mariadb lol
You can connect to MariaDB by port, but not by socket. To connect by socket create a symlink for the socket:
/bin/ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
or alternatively use the updated configure string from the tutorial which sets the Debian socket path.
Where is the "string from the tutorial which sets the Debian socket path" ib this tutorial?
This comment is about a older version of this tutorial and does not applyto the cirrent version. The string is:
./configure --prefix=/opt/php-7.0.5 --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
as shown in the tutorial.
This guide also works for Ubuntu 15.10 with the following changes:
- instead of libjpeg62-turbo-dbg I had to install libjpeg-turbo8-dbg
- to create the system startup links, instead of using insserv I ran 'update-rc.d php-7.0.0-fpm defaults'
And one tiny thing: comments in /opt/php-7.0.0/etc/php-fpm.conf are with ; instead of #
error 502 nginx
Check the error.log of the website.
unix:/var/lib/php5-fpm/web.sock failed (2: No such file or directory)
Hi,
you should disable "Use Socket For PHP-FPM" on options menu for your web domain. Swtiching from unix socket to tcp socket.
Regards,
L.
I can't install wordpress, joomla and drupal after i follow this and changed to PHP7 in ispconfig. It seems permission I need to set. I couldn't figure it out.
Run:
/bin/ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
to create a symlink for the MySQL socket.
Thank you for this post!
Everythink works
Thank You :)
Now i have error 500 joomla.But wordpress work good
You can find details on the source of the error in the error.log of the website. Not all CMS support PHP 7 yet or they may need additional PHP modules.
This is what I get:
Error 500 and on the log file:
[fastcgi:error] [pid 27711] (2)No such file or directory: [client ip:54113] FastCGI: failed to connect to server "/var/www/clients/client7/web11/cgi-bin/php5-fcgi-ip-80-domain": connect() failed
Hi,
when enabling php-fpm apache looks for it on port 9010 and not on the port 8999 as mentioned above.
I'm still looking for a 'ispconfig' solution but in the meanwhile you can go to /etc/apache2/sites-available and nano yourdomaincom.host and change the port wherever you can.
Alternatively you can change the php7 port to 9010 and it works greatly but then you can't use php5xx (php-fpm) unless you change again the port.
Hope this helps!
Aisfrond
You mix up port 8999 which is the instance for the www-data user with the insatnce created by ISPConfig for the website 9010. There is no need to edit any config files, just leave it as it is, you will see in phpmyadmin that the correct php version will show up in phpinfo after 60 seconds.
nano /opt/php-7.0.0/lib/php.ini
set cgi.fix_pathinfo = 0
Thanks for this! However I got a error 500 if I use php-FPM.
52] (104)Connection reset by peer: [client xxx:23480] FastCGI: comm with server "/var/www/clients/client0/web2/cgi-bin/php5-fcgi-xxxx" aborted: read failed
[Tue Dec 15 12:49:54.630691 2015] [fastcgi:error] [pid 4452] [client xxxx:23480] FastCGI: incomplete headers (0 bytes) received from server "/var/www/clients/client0/web2/cgi-bin/php5-fcgi-xxxx"
Why fast-cgi erros If I want to use php-FPM?
The apache module that does the connection to the php-fpm process is mod-fastcgi, that's why the error message contains the word fast-cgi. Most likely your php-fpm process is not started. If you need help with your setup, please us ethe forum.
Ok so:
systemctl status php-7.0.0-fpm.service -l
I had:
ERROR: unable to bind listening socket for address '127.0.0.1:8999': Address already in use (98)
I changed to another port, like 8998. Restarted Apache. And it works now. thank!s
Hello, i've done everything one by one but wordpress index page is not renderred. it loads the source of the php file instead of executing it.
<?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' );Hi,
I tried to start php 7 and it's work on command line
etc/init.d/php-7.0.0-fpm startStarting php-fpm done
./php --versionPHP 7.0.0 (cli) (built: Dec 6 2015 10:54:11) ( NTS )Copyright (c) 1997-2015 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
But when I select Php7-fpm from website configuration, php is not interpreted
ensure that you have mod_fastcgi (not to be mixed up with mod_fcgi) is installed on the server and enabled in apache.
Ok now i've got cgi/fastCGI but not php-fpm
[pid 23603] [client ip:51456] FastCGI: incomplete headers (0 bytes) received from server "/var/www/clients/client1/web7/cgi-bin/php5-fcgi-*-80-myndd.com"
Php info show :
Server API CGI/FastCGIWhen i do
sudo lsof -U | grep php
i've got
php-fpm 22927 root 5u unix 0x0000000000000000 0t0 35385577 P35385578
php-fpm 22927 root 7u unix 0x0000000000000000 0t0 35385578 P35385577
php-cgi 24388 web7 0u unix 0x0000000000000000 0t0 35390367 /var/lib/apache2/fcgid/sock/24254.0
mod_fcgi is installed and enabled.
You have to enable mod_fastcgi AND mod_fcgi as described in the ISPConfig perfect server tutorial. Currently, you have only mod_fcgi enabled and therefore only php-fcgi works but not php-fpm which requires the mof_fasrtcgi module.
I have both and still get:
[Mon Jan 04 04:33:25.244931 2016] [fcgid:warn] [pid 26708] [client xxx.xxx.xxx.xxx:5137] mod_fcgid: stderr: PHP Fatal error:...
Hello,
Did all parts of your tuto, good job.
php -v show me on php 5.6, with opCache ou zend cache on 7.0 (didn't remember which one exactly)
Is there any easy ways to check what was wrong or what isn't working?
Adding code mentioned in this tut and all I found on other tuts can't enable opcache!!! Php -v and opcache gui script say: opcache not enabled
Check the output of the phpinfo() command, if it shows opcache then it is enabled and your opcache detection script might have a failure or is not php7 compatible.
I had trouble with apt-get install libjpeg62-turbo-dbg i left it our and all the other packages installed. I noticed that
The following extra packages will be installed:
comerr-dev krb5-multidev libgcrypt11-dev libgnutls-dev libgnutlsxx27
libgpg-error-dev libgssrpc4 libidn11-dev libjpeg-turbo8-dev libjpeg8-dev
libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-7 libldap2-dev libp11-kit-dev
libpam0g-dev librtmp-dev libssl-doc libtasn1-6-dev
I hope this will be alright to continue with libjpeg-turbo8-dev
I use NGINX without ISPConfig! How to use php7/php-fpm on the whole System?
*.html files are accessible *.php files not... (i get a promt to download the php files)
cd /opt/php-7.0.0/bin => ./php --version: worksphp --version: not!
Hi,
so I installed everything as shown here and it is working perfectly. The only issue is that I could not get memcache, memcacged and the other extensions to work. I was having issues with ioncube as well. The problem is that I am running ispconfig3 on rasberiP with Arm processors, after long research I found that I have to use ioncube loader specifically for Rasberry Pi in order to get it working, but I was not able to find memcache and other for Rasberri Pi. Do you know, if such occur ?
The error I am getting is: Unable to load shared library file - I was getting same error for ioncube, but using the correct loader for Rasberry Pi fixed it. Now I am getting the same for all the other extensions described in the tutorial.
Hi,
I followed the guide for PHP 7.0.1 and it works fine (I replaced every php-7.0.0 with php-7.0.1).
Tested with ispconfig 3 + Apache and ispconfig 3 + Nginx.
Regards,
L.
If someone is interested, I also backported debian packages, but in order to not interfer with php5, you need to update to php5.6 before (I also backported this packages).
So this would only be for test environements.
Great tutorial, thanks a lot !
But actually I have this error /usr/bin/env: php: No such file or directory when trying to use composer. PHP 7 is correctly installed, indeed php -v shows what I expect.
PATH is not correctly configured, does not it; should symbolic link fix this ? (OS: debian 8)
I did this with php7.0.2 and it worked perfect!One question though, How do we update it? I am all new to not using apt-get.
The PHP is compiled manually, so you can not update this PHP version with apt-get. There are 2 options: Either you compile a new php version (e.g. 7.0.3) in a new folder and install it under a new name in ispconfig, then switch the sites to the new version, or you overwrite the old php version by compiling the new one in the same folder.
Hello
I get this errors in error.log
2016/01/18 18:23:31 [error] 6011#0: *11 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined variable: data in /var/www/clients/client1/web1/web/includes/carte_flash.inc.php on line 15
PHP message: PHP Notice: Undefined variable: town_links in /var/www/clients/client1/web1/web/includes/town_links.inc.php on line 13
PHP message: PHP Notice: Undefined variable: ads_250 in /var/www/clients/client1/web1/web/includes/ads_250.php on line 2
PHP message: PHP Notice: Undefined variable: search_widget in /var/www/clients/client1/web1/web/includes/right_content.inc.php on line 7
PHP message: PHP Notice: Undefined variable: ret in /var/www/clients/client1/web1/web/includes/saved_towns.inc.php on line 7
PHP message: PHP Notice: Undefined variable: footer_content in /var/www/clients/client1/web1/web/includes/footer_content.inc.php on line 4
These are warnings and not errors. They inform you about missing variable declarations in your php code.
I would like to enabel / install the intl libs, how do I go about it or do I have to reinstall ?
First you have to install libicu-dev:
apt-get install libicu-dev
then you can try to install it as module with pecl (I tried that yesterday at a client server but it did not work for me, did not had the time to investigate the issue in detail). I then just recompiled php with intl and that worked flawlessly.
i found a error. correct locations: cp /usr/local/src/php5-build/php-7.0.2/php.ini-production /opt/php-7.0.2/ect/php.ini
The command in the tutorial that copys the file to lib is fine and not an error.
What is the fix on the socket for nginx/centos 7/mariadb? Not sure why it is referencing php5 sock..? connect() to unix:/var/lib/php5-fpm/web5.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: mydomain.com, request: "POST /wp-admin/setup-config.php?step=2 HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php5-fpm/web5.sock:"
This tutorial is for Debian only, not CentOS. It is unlikely that this will work on CentOS without major modifications.
Paths don't match, typo ;)"Then open /opt/php-7.0.2/etc/php-fpm.conf and ...
nano /opt/php-7.0.2/etc/php-fpm.d/www.conf
Hi,
i installed php7 from official source before. php5 was removed automatically. php-fpm7.0 is running. But i get a 500 internal server error when trying to access ispconfig. Could you please help me?
Replacing the system PHP 5.x with PHP 7 will cause the system to fail as ispconfig 3.0.5.x expects a PHP version between 5.2 - 5.6 for its interface and server process. Please undo the PHP replacement that and then install an additional PHP 7 version as described here to get PHP 7 support.
Thank you for this tutorial, but I have problem.
I can't start php-7.0.3-fpm.service (systemctl enable php-7.0.3-fpm.service), because I get this error:
update-rc.d: error: php-7.0.3-fpm Default-Start contains no runlevels, aborting.
Can you help? Thanks.
Worked flawlessly!! Thank you so much :D
ok something is actually not working. it doesn't interprete php.. do i have to add some line to apache2 config or add a php mod to the apache mods folder? or do i have to have php5 installed too? or do i have to manually specify a mime type for it? i'm really not very into such stuff and actually only want it up and running so i can move to webapp building... i think setting up cassandra is also going to be a challenge for me... i have no clue. fcgi and fastcgi are both enabled as also stated in the log file. i really followed every step except the ispconfig section as this looks like it needs working php already.here the apache logfile content:
root@geo:/etc/apache2# vim /var/log/apache2/error.log[Thu Mar 03 03:09:21.583385 2016] [:notice] [pid 1058:tid 140390004258688] FastCGI: process manager initialized (pid 1058)[Thu Mar 03 03:09:21.584409 2016] [mpm_event:notice] [pid 1055:tid 140390004258688] AH00489: Apache/2.4.10 (Debian) mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_fcgid/2.3.9 configured -- resuming normal operations[Thu Mar 03 03:09:21.584526 2016] [core:notice] [pid 1055:tid 140390004258688] AH00094: Command line: '/usr/sbin/apache2'
and the php-fpm log:
root@geo:/etc/apache2# vim /opt/php-7.0.3/var/log/php-fpm.log[03-Mar-2016 03:25:11] NOTICE: fpm is running, pid 1440[03-Mar-2016 03:25:11] NOTICE: ready to handle connections~
The actual apache and nginx PHP setup is completely handled by ISPConfig (you can select php 7 in the website setings in fpm and fcgi mode) and yes, PHP5 is installed on an ISPConfig server as well (see perfect server tutorials) as this here is an additional PHP version that allows you to switch between php5 and php7 in the website in ISPConfig.
You should change the init script from
# Required-Start: $all
# Required-Stop: $all
to
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
Otherwise you will end up in cyclic dependent services when installing more than one version according to this tutorial.
I can not send mails from PHP, something is missing?
As mentioned by @merkur comments, it worked for me on my Ubuntu Server 14.04 x64. I Also changed the PHP version to 7.0.4 editing the related commands shown above, very easy!
Hi! In this comment I want to ask if I can still use my "suPHP_ConfigPath" directives on my .htaccess files on domains seto to PHP-FPM. If no, is there a .htaccess config to force PHP-FPM to load custom user php.ini files?
Thanks!
Works like a charm with php 7.0.4 - for wheeze, only skip the systemctl stuff.
Thanks a lot for this nice Step by Step HowTo.
On debian 7, getting this error:
28.03.2016-13:57 - WARNING - Apache did not restart after the configuration change for website mysite.com. Reverting the configuration. Saved non-working config as /etc/apache2/sites-available/mysite.com.vhost.err 28.03.2016-13:57 - WARNING - Reason for Apache restart failure: Failed to get D-Bus connection: No connection to service manager.
Up and running on Ubuntu 14.04 server.
Thanks for what a very usefull info!
Has anyone hints to add xdebug to this installation?
Any solution regarding memcached yet? Many thanks
Hi,
On debian 8, getting Error 500 and on the log file:
[fastcgi:error] [pid 22406] (2)No such file or directory: [client xxx:26399] FastCGI: failed to connect to server "/var/www/clients/client1/web2/cgi-bin/php5-fcgi-*-80-mydomain.com": connect() failed[fastcgi:error] [pid 22406] [client xxx:26399] FastCGI: incomplete headers (0 bytes) received from server "/var/www/clients/client1/web2/cgi-bin/php5-fcgi-*-80-mydomain.com"
The previous answers did not help to solve the problem#systemctl status php-7.0.5-fpm.service -lshows:
php-7.0.5-fpm.service - The PHP 7 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php-7.0.5-fpm.service; enabled) Active: inactive (dead)Apr 24 01:19:07 isp systemd[1]: Unit php-7.0.5-fpm.service cannot be reloaded because it is inactive.
sudo apt-get install gcc make autoconf libc-dev pkg-configsudo apt-get install zlib1g-devsudo apt-get install libmemcached-devcd /usr/local/src/php5-buildgit clone https://github.com/php-memcached-dev/php-memcachedcd php-memcachedgit checkout php7/opt/php-7.0.6/bin/phpizePATH=/opt/php-7.0.6/bin:$PATH ./configure --disable-memcached-saslmakesudo make install
==> This one doesnt worksudo bash -c "echo extension=memcached.so > /opt/php-7.0.6/lib/conf.d/memcached.ini"
==> I could it only get it to work when i add it at example: /var/www/conf/web1/php.ini
sudo service php-7.0.6-fpm restart================================================================================sudo apt-get install gcc make autoconf libc-dev pkg-configsudo apt-get install zlib1g-devsudo apt-get install libmemcached-devcd /usr/local/src/php5-buildgit clone https://github.com/krakjoe/apcu
cd apcu
git checkout sevenmake cleanPATH=/opt/php-7.0.6/bin:$PATH ./configure make -j 4make installcd ..rm -rf ./apcu
==> and again, This one doesnt work# add extensionecho "extension=apcu.so" > /opt/php-7.0.6/lib/conf.d/ext-apcu.iniecho "apc.enable_cli = On" >> /opt/php-7.0.6/lib/conf.d/ext-apcu.ini
==> I could it only get it to work when i add it at example: /var/www/conf/web1/php.ini
i add
--with-config-file-scan-dir=/opt/php-7.0.6/lib/conf.d
when i compiled php-7.0.6
example:
./configure --prefix=/opt/php-7.0.6 --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 --with-config-file-scan-dir=/opt/php-7.0.6/lib/conf.d
For Magento 2 you need install
apt-get install libicu-devand configure with --enable-intl
How can i remove php7.0.2 before install the new version?
Uninstall outdated source builds of PHP 7.0.x - https://www.howtoforge.com/community/threads/uninstall-php-7-make-uninstall.73706/
Hi
I found a easier alternative that is also nicer to update: Use the PPA https://launchpad.net/~ondrej/+archive/ubuntu/php.
Here is how I successfully installed PHP7-FPM in parallel with PHP5.5-FPM on Ubuntu 14.04:
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php7.0-fpm
apt-get install php7.0-mysql
apt-get install php7.0-imap
apt-get install php7.0-mbstring php7.0-gd php7.0-zip
a2enmod proxy_fcgi
a2enconf php7.0-fpm
update-alternatives --set php /usr/bin/php5
Beware that enabling proxy_fcgi causes troubles with ISPConfig 3.0.5.4 when using PHP-FPM over Unix-Sockets, since the configuration is buggy in that case. See https://git.ispconfig.org/ispconfig/ispconfig3/merge_requests/343. You can also manually fix the file /usr/local/ispconfig/server/conf/vhost.conf.master
The last command changes the target of /usr/bin/php back to PHP5, the system default, which is recommended.
Apart from that, it is working well and enables to run PHP5 and PHP7 in FPM-Mode in parallel.
in case you got the error : configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
Then you need to install the Imap headers of the c-client library :
apt-get install libc-client2007e-dev
Hi guys! Thanks for the tutorial!
I have a strange behaviour when I try to start the new 7.0.7 FPM
# /etc/init.d/php-7.0.7-fpm start
Starting php-fpm [13-Jun-2016 12:25:02] ERROR: failed to open error_log (/opt/php-7.0.5/var/log/php-fpm.log): No such file or directory (2)
[13-Jun-2016 12:25:02] ERROR: failed to post process the configuration
[13-Jun-2016 12:25:02] ERROR: FPM initialization failed
failed
It read the old version 7.0.5 but I have deleted that obsolete directory. What have I to do? How to fix it?
thanks
on step :
Copy php.ini and php-fpm.conf to the correct locations:
I've this message : (in french)
cp: impossible de créer le fichier standard « /opt/php-7.0.7/lib/php.ini »: Aucun fichier ou dossier de ce type
On thi step, i've the same message :(
nano /opt/php-7.0.7/etc/php-fpm.conf
You forgot this too: (To make php executable from everywhere)
cp /opt/php-7.0.7/php /bin/
I did not forgot this, the php binary should not be copied to /bin. When you do that, then you replace the system PHP with this additional PHP version, this is not intended and will break ISPConfig.
Hello any information on how to make geoip work with PHP 7 would be aprpeciated. Maybe in the next tutorial update it would be very useful. Thanks a lot, very good tutorial as always.
The php-7.0.9 source from github (or http://git.php.net/) does not include a `configure` script, to create it run `./buildconf --force` from within the php-7.0.9/ source directory.
Does this HOWTO work for Debian 7 as well?
Thanks
I need the intl plugin so I had to install libicu-dev and add --enable-intl to the configure
But the plugin is not available in PHP. Anyone any idea?
in order to get CakePHP up and running, I need to install the intl extention. Where and how can I include this in this workflow?
Hi, any working solution for adding memcached to this installation?
Or maybe any tutorial how to set lower 7.+ version of PHP with memcached support for IspConfig 3.1?
I tried this tutorial with notes from merkur and it works perfect with PHP 7.1.8 and Ubuntu Server 14.04 LTS, thank you!