Install PHP 7.1 on Debian Jessie ARM 64bit architecture

I wanted to test PHP7 on my Debian Jessie install, but latest offered package in the repositories was 5.6.30+dfsg-0+deb8u1.

In order to install PHP 7.1 which was the latest at the time of this article, you need to add following repository by running following commands:

apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update

After apt-get update has finished you need to install PHP 7.1 and some of it’s modules.  Since I am using lighttpd you might need similar packages:

apt-get install php7.1-cli php7.1-cgi php7.1-mysql php7.1-mcrypt php7.1-mbstring

Last one “php7.1-mbstring” is needed in order for phpMyAdmin to work, otherwise access to phpMyAdmin will fail with log messages like these:

(mod_fastcgi.c.2702) FastCGI-stderr: PHP Fatal error: Uncaught Error: Call to undefined function __() in /usr/share/phpmyadmin/libraries/core.lib.php:235
(mod_fastcgi.c.2702) FastCGI-stderr: Stack trace:
(mod_fastcgi.c.2702) FastCGI-stderr: #0 /usr/share/phpmyadmin/libraries/core.lib.php(308): PMA_fatalError('The [a@./url.ph...')
(mod_fastcgi.c.2702) FastCGI-stderr: #1 /usr/share/phpmyadmin/libraries/common.inc.php(90): PMA_warnMissingExtension('mbstring', true)
(mod_fastcgi.c.2702) FastCGI-stderr: #2 /usr/share/phpmyadmin/index.php(12): require_once('/usr/share/phpm...')
(mod_fastcgi.c.2702) FastCGI-stderr: #3 {main}
(mod_fastcgi.c.2702) FastCGI-stderr: thrown in /usr/share/phpmyadmin/libraries/core.lib.php on line 235

In order for lighttpd to start with newly installed PHP 7.1 instead of PHP 5 which was used earlier you need to edit file “/etc/lighttpd/conf-enabled/15-fastcgi-php.conf”, but please make sure to create a backup in case you want to revert to previous configuration.

Please search for the line:

"bin-path" => "/usr/bin/php-cgi",

and change it to:

 "bin-path" => "/usr/bin/php-cgi7.1",

So your edited config file should look like this:

# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi

## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
 ((
 "bin-path" => "/usr/bin/php-cgi7.1",
 "socket" => "/var/run/lighttpd/php.socket",
 "max-procs" => 1,
 "bin-environment" => (
 "PHP_FCGI_CHILDREN" => "4",
 "PHP_FCGI_MAX_REQUESTS" => "10000"
 ),
 "bin-copy-environment" => (
 "PATH", "SHELL", "USER"
 ),
 "broken-scriptfilename" => "enable"
 ))
)

After successful restart of lighttpd using /etc/init.d/lighttpd restart, you should be able to see in the results of phpinfo(); command that you are running PHP 7.1.x:

Leave a Reply

Your email address will not be published. Required fields are marked *