How to install latest php version on RPI3B+ with Apache2.4.25 Raspian

Hello everbody.

I´m looking for a way to install the latest php version on my rpi3+B. I´m using apache2.45.25 on raspian. I know that there is no repository for arm and I tried to compile it with this instructions:

http://shaunvos.me/2018/06/14/installing-php-7-2-6-on-raspian-stretch-on-raspberry-pi-3-model-b/

I think it is working because of this:

@berrypi:/opt/php-7.2/bin $ php -v
PHP 7.0.30-0+deb9u1 (cli) (built: Jun 14 2018 13:50:25) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.30-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies
@berrypi:/opt/php-7.2/bin $ ./php -v
PHP 7.2.9 (cli) (built: Aug 27 2018 17:39:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
pi@raspberrypi:/opt/php-7.2/bin $

So I know my Pi can handle php 7.2.x, but how do I implement it to apache that it can be used by apache and the webserver?

cheers :wink:

I got it now for the console. When I type php -v it´s now the new version:

berrypi:/var$ php -v
PHP 7.2.9 (cli) (built: Aug 27 2018 17:39:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

But when I open .php file with phpinfo(); its even the old php version:

What can I do that apache2 use the latest php version, too?

Backtopic (only for helping others later): I was looking at the old version of php to see how it is implemented in the system. I tried it with the latest version and these links helped me with the method ‘try and error’ to get it working in the console:

After installing libapache2-mod-php7.2 you need to disable/remove the php7.0 module and enable the php7.2 one.

It should be:

a2dismod php7.0
a2enmod php7.2

or

apt purge libapache2-mod-php7.0
apt install libapache2-mod-php7.2

€: Ah you compiled it from source. So no apt install of course. But you use mod-php with apache right? So basically the 7.2 version of the mod is needed and need to be enabled as above.

And Jep, PHP7.2 works fine on RPi3, I use it on RPi2 here for some time (although Raspbian Buster).

So finally I got it working in apache2. I forgot to install with

sudo apt-get install apache2-dev

the development version of apache. In this version is apxs2. So I reconfigured my compilation with adding the --with-apxs2=/usr/bin/apxs2 \ flag.
Now I got compiled a module for apache that it can handle the PHP.
Then I just needed to edit the php7 files in /etc/apache2/conf-&mod-avaible. Of course I copied them.
After implementing libapache2-mod-php7 to Apache conf files and your a2dismod and a2enmod php7.2, it is finally working now with the correct PHP version.

But I did something wrong. I think for Nextcloud a module from php is missing.
So what module it can be?

php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib
[Zend Modules]

I did it this way to configure the compiler:

./configure
–prefix=/opt/php-7.2
–with-config-file-path=/opt/php-7.2/etc
–with-apxs2=/usr/bin/apxs2
–with-zlib-dir
–with-freetype-dir
–enable-mbstring
–with-libxml-dir=/usr
–enable-soap
–enable-calendar
–with-curl
–with-mcrypt
–with-zlib
–with-gd
–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=/usr/lib/arm-linux-gnueabihf
–enable-ftp
–with-imap
–with-imap-ssl
–with-kerberos
–with-gettext
–with-xmlrpc
–with-xsl
–enable-opcache
–enable-fpm

I used memcaching, and I think this is the problem. I will look into it :wink:

EDIT: Yep I think the only module which is missing is memcache :slight_smile:
Now I´m looking for a solution to install memcache :smiley:

Do you have a distributed Nextcloud instance? Otherwise I would just use APCu as local memory cache, which is recommended anyway.

So this would be --with-apcu --enable-apcu, I guess. Then 'memcache.local' => '\\OC\\Memcache\\APCu', within your config.php.

Btw. if you already compiling. Did you consider to use Redis for file locking? It is recommended as well, should speed up NC a bid and reduces load on MySQL/MariaDB database.
apt install redis-server
and use php-redis module (which depends on php-igbinary again). Check here for NC config: https://docs.nextcloud.com/server/13/admin_manual/configuration_files/files_locking_transactional.html

  • In case of single server system, use the second method via socket.