[Tutorial] Upgrade PHP, PHP-FMP to version 7.4 Arbiam 20.11 NextcloudPi 20.02: No errors in Nextcloud log

Hello,

I offer you a small howto to update or install PHP7.4 on Debian Buster.
It’s possible that a few errors may persist because this was not achieved immediately.

My server:
Linux Armbian 20.11 Tamandua kernel linux cloud 5.4.77-odroidxu4
Apache/2.4.38
Mysql 10.3.25-MariaDB
Php 7.3.19-1 upgrade to 7.4.13
Nextcloud 20.0.2.2

Let’s go to:

#php -v

PHP 7.3.19-1~deb10u1 (cli) (built: Jul 5 2020 06:46:45) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright © 1998-2018 Zend Technologies
with Zend OPcache v7.3.19-1~deb10u1, Copyright © 1999-2018, by Zend Technologies

UPDATE YOUR SYSTEM AND ADD PPA Repository FOR PHP4
We will add ppa:ondrej/php PPA repository which has the latest build packages of PHP (Ondrey Sury)

#apt update
#apt -y install lsb-release apt-transport-https 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” | sudo tee /etc/apt/sources.list.d/php.list
#apt update

#apt install vim
but you can use nano!
#apt install imagemagick libmagickcore-6.q16-6
if not installed

INSTALL AND CONFIGURE PHP7.4 and PHP7.4-fpm (FastCGI Process Manager)

#apt -y install php7.4
#apt install libapache2-mod-php7.4

Suggested packages:
autoconf-archive gnu-standards autoconf-doc gettext uw-mailutils libssl-doc libtool-doc gfortran | fortran95-compiler gcj-jdk m4-doc dh-php php-pear
Recommended packages:
libltdl-dev ghostscript ttf-dejavu-core pkg-php-tools
Creating config file /etc/php/7.4/fpm/php.ini with new version

Use the next command to install additional packages:

#apt-get install php7.4-{common,bcmath,bz2,intl,gd,mbstring,mysql,zip,cli,fpm,json,pdo,mbstring,curl,xml,imagick,tidy,xmlrpc,dev,imap,opcache,soap} -y

#apt install php7.4-gmp

libapache2-mod-php or php-cgi packages, enable run PHP scripts from your web browser
php-cli package, enable to run PHP scripts at a terminal prompt

DISABLE PHP 7.3
disable Module php7.3

#a2dismod php7.3

show installed php versions

#ls -lrt /etc/php
total 24
drwxr-xr-x 5 root root 4096 Jan 9 2020 7.3
drwxr-xr-x 3 root root 4096 Jan 9 2020 7.2
drwxr-xr-x 6 root root 4096 Nov 15 14:55 7.4
drwxr-xr-x 3 root root 4096 Nov 15 14:55 7.1
drwxr-xr-x 3 root root 4096 Nov 15 14:55 7.0
drwxr-xr-x 3 root root 4096 Nov 15 14:55 5.6

Purge old configuration

#apt purge php7.3 libapache2-mod-php7.3
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package ‘libapache2-mod-php7.3’ is not installed, so not removed
The following packages will be REMOVED:
php7.3*
0 upgraded, 0 newly installed, 1 to remove and 30 not upgraded.
After this operation, 78.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database … 40722 files and directories currently installed.)
Removing php7.3 (7.3.19-1~deb10u1) …

#cd /etc/apache2/conf-enabled
#ls -A -l
total 4
lrwxrwxrwx 1 root root 30 Jan 9 2020 charset.conf -> …/conf-available/charset.conf
lrwxrwxrwx 1 root root 28 Jan 9 2020 http2.conf -> …/conf-available/http2.conf
lrwxrwxrwx 1 root root 44 Jan 9 2020 localized-error-pages.conf -> …/conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Jan 9 2020 other-vhosts-access-log.conf -> …/conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 33 Jan 9 2020 php7.3-fpm.conf -> …/conf-available/php7.3-fpm.conf
lrwxrwxrwx 1 root root 33 Nov 15 22:06 php7.4-fpm.conf -> …/conf-available/php7.4-fpm.conf
-rw-r–r-- 1 root root 2177 Nov 21 23:43 security.conf
lrwxrwxrwx 1 root root 36 Jan 9 2020 serve-cgi-bin.conf -> …/conf-available/serve-cgi-bin.conf

#unlink php7.3-fpm.conf

#rm /var/log/php7.3-fpm.log

#apt update
The following package was automatically installed and is no longer required:
php7.3-xxxxx
Use ‘apt autoremove’ to remove it.

#apt autoremove
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
php7.3-xxxxx

#dpkg -P $(dpkg -l | awk ‘$1~/^rc$/{print $2}’)

PHP7.4 CONFIGURATION

#a2enmod proxy_fcgi setenvif
#a2enconf php7.4-fpm
#a2enmod php7.4 (php not fpm is used for login page, so don’t disable it)

By default, when libapache2-mod-php7.4 is installed, the Apache 2 Web server is configured to run PHP scripts using this module. Please verify if the files /etc/apache2/mods-enabled/php7.4.conf and /etc/apache2/mods-enabled/php7.4.load exist. If they do not exist, you can enable the module using the a2enmod command.

Adjust the configuration
PHP configurations related to Apache is stored in /etc/php/7.4/apache2/php.ini
Go to the ‘/etc/php/7.4’ directory

#cd/etc/php/7.4/

Edit the php.ini files for apache2

#vi /etc/php/7.4/apache2/php.ini
; Maximum amout of memory a script may consume (change the default value 128M)
_limit = 512M

Save and exit.

Edit the php.ini files for php-fpm and php-cli using vi

#vi /etc/php/7.4/fmp/php.ini
#vi /etc/php/7.4/cli/php.ini

Uncomment the ‘date.timezone’ line and change the value with your own timezone.

date.timezone = Europe/Paris
Uncomment the ‘cgi.fix_pathinfo’ line and change the value to ‘0’.
cgi.fix_pathinfo=0

Save and exit.

PHP FPM configuration file is /etc/php/7.4/fpm/pool.d/www.conf.
edit the php-fpm pool configuration ‘www.conf’.

#vi /etc/php/7.4/fpm/pool.d/www.conf
Uncomment those lines below.
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

Save and exit.

To activate the new configuration, you need to:
Restart the apache2 service

#systemctl restart apache2 (= systemctl restart apache2.service, = service apache2 restart)

Restart the PHP7.4-FPM service and enable it to launch every time on system boot:

#systemctl restart php7.4-fpm
#systemctl enable php7.4-fpm

TESTING
Check the new configuration using the following command
PHP

#php -v
PHP 7.4.12 (cli) (built: Nov 3 2020 14:31:48) ( NTS )
Copyright © The PHP Group
Zend Engine v3.4.0, Copyright © Zend Technologies
with Zend OPcache v7.4.12, Copyright ©, by Zend Technologies

#apt-cache policy php7.4
php7.4:
Installed: 7.4.12-3+0~20201103.32+debian10~1.gbpa97e22
Candidate: 7.4.12-3+0~20201103.32+debian10~1.gbpa97e22
Version table:
*** 7.4.12-3+0~20201103.32+debian10~1.gbpa97e22 500
500 https://packages.sury.org/php buster/main armhf Packages
100 /var/lib/dpkg/status

#systemctl is-active php7.4

PHP-FPM service

#ss -xa | grep php

#systemctl status php7.4-fpm
Listing all loaded PHP modules:
#php -m

APACHE2

#apache2 -S

#apache2ctl -v
Server version: Apache/2.4.38 (Debian)
Server built: 2020-08-25T20:08:29

#apachectl -t -D DUMP_MODULES | grep mpm
mpm_event_module (shared)

#apache2ctl -t (verify the config file)
Syntax OK

MySQL

#systemctl status mariadb

SMB/CIFS Share via nextcloud app External Storage, if needed:

#apt update
#apt install smbclient

the followings steps avoid php errors if you have an external SMB mount:

#cd /var/www/nextcloud
#sudo -u www-data php occ files:scan --all
Starting scan for user 1 out of x (xxx)
mkdir failed on directory /var/run/samba/msg.lock: Permission denied

Install php dev library

#apt install libsmbclient-devroot
#pear config-get php_dir
/usr/share/php

pecl download the php extension as source and phpize is a simple scipt bash which ensures the local compilation of the extension with gcc. This script call sed in /usr/bin, so if sed is not in this location, you have to create a symlink:

#type -a sed
sed is /bin/sed
(armbian 20.x, linux raspberrypi 5.4.x, and probably other linux ditrib)

Create a sed symlink in /urs/bin

#ln -s /bin/sed /usr/bin/sed
#cd /usr/bin
#ls -l sed
lrwxrwxrwx 1 root root 8 Dec 5 10:05 sed -> /bin/sed

Install php smbclient

#pecl channel-update pecl.php.net
Updating channel “pecl.php.net
Update of Channel “pecl.php.net” succeeded
root@cloud:/etc/php/7.4/fpm# pecl install smbclient
downloading smbclient-1.0.0.tgz …
Starting to download smbclient-1.0.0.tgz (32,017 bytes)
…done: 32,017 bytes
4 source files, building
running: phpize

Build process completed successfully
Installing ‘/usr/lib/php/20190902/smbclient.so’
install ok: channel://pecl.php.net/smbclient-1.0.0
configuration option “php_ini” is not set to php.ini location

You SHOULD NOT add “extension=smbclient.so” to php.ini
extensions are loaded in /etc/php7.4/mods-available

Restart the services

#systemctl restart apache2
#systemctl restart php7.4-fpm

Now you should be able to add an SMB/CIFS share, and see that no error is recorded in the nextcloud log file regarding the smb/cifs share.

https://cloud.com/index.php/settings/admin/logging

Aucun journal serveur

Tout fonctionne à merveille

Enjoy
konki

bibliography :











https://github.com/nextcloud/docker/issues/754 (sbmc docker)
1 Like

Could you please clarify how you came to these conclusions? My experience is different (but, I could go wrong too):

  • As long as mod-php is switched on in Apache, it will never use php-fpm. So what’s the purpose of mod-php if you want to use php-fpm?
  • There’s nothing in Nextcloud that is strictly requiring mod-php. I have instances running where I did not install mod-php at all.

Regards,
it25fg.

thanks for your remark, you’re right, Nextcloud only uses php and disabling the php module effectively disables the server. fmp-php is not used, I’ve mixed up my reference readings.

[https://docs.nextcloud.com/server/20/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation]

Would there be any interest in using it? The PHP module has the disadvantage of overloading the server, because each Apache process is attached to a complete PHP engine.

konki

i’ve moved this topic to “How to”-category, slighly adapted it’s title and made it a wiki so everyone could adjust it.

I hope that’s ok for you @konki

1 Like

yes of course, it’s a desire of sharing which animates me, I’m only a simple computer user and if my knowledge is rather good in the management of the linux systems, they remain basic with regard to Apache and PHP! I’m able to sort and select the reliable sources of information but these are all things.

konki

1 Like