Humhub v1.11.1 : Migration de php 7.3 vers php 7.4


J’ai du faire un update de PHP afn de pouvoir mettre la dernière version de Humhub :

sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo 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
sudo apt update
sudo apt -y install php7.4

Ma release de Debian :

# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# php -v
PHP 7.4.29 (cli) (built: Apr 22 2022 06:44:32) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies

La seconde étape :

# sudo a2dismod php7.3
Module php7.3 disabled.
To activate the new configuration, you need to run:
  systemctl restart apache2
# sudo a2enmod php7.4
Considering dependency mpm_prefork for php7.4:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.4:
Enabling module php7.4.
To activate the new configuration, you need to run:
  systemctl restart apache2
# systemctl restart apache2

Ensuite rien ne fonctionnait … j’ai donc ajouté ceci :

# apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl 
php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring 
php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
# systemctl restart apache2

HumHub : Compression d’image …

J’ai pu voir dans la documentation que c’était possible : https://docs.humhub.org/docs/admin/uploads/ . A noter que j’utilise la version : 1.8.2.

J’ai donc modifié la configuration dans /var/www/humhub/protected/config/common.php :

<?php
/**
* This file provides to overwrite the default HumHub / Yii configuration by your local common (Console and Web) environments
* @see http://www.yiiframework.com/doc-2.0/guide-concept-configurations.html
* @see http://docs.humhub.org/admin-installation-configuration.html
* @see http://docs.humhub.org/dev-environment.html
*/
return [
'modules' => [
'file' => [
'imageMaxResolution' => '1920x1080',
'imageJpegQuality' => 75,
'imagePngCompressionLevel' => 9,
'imageWebpQuality' => 75,
]
]
];

Ensuite j’ai lancé la commande :

# sudo su
# /usr/bin/php /var/www/humhub/protected/yii file/downscale-images
*** File module console

Downscaling uploaded files:....

Afin de compresser les images précédentes, mais j’ai eu un crash :

Exception 'Imagine\Exception\RuntimeException' with message 'Resize operation failed'

in humhub/protected/vendor/imagine/imagine/src/Imagick/Image.php:295

Caused by: Exception 'ImagickException' with message 'cache resources exhausted ...

in /humhub/protected/vendor/imagine/imagine/src/Imagick/Image.php:292

Stack trace:
#0 /humhub/protected/vendor/imagine/imagine/src/Imagick/Image.php(292): Imagick->resizeimage(1920, 2560, 0, 1)
#1 /humhub/protected/humhub/modules/file/libs/ImageHelper.php(129): Imagine\Imagick\Image->resize(Object(Imagine\Image\Box))
#2 /humhub/protected/humhub/modules/file/commands/FileController.php(93): humhub\modules\file\libs\ImageHelper::downscaleImage(Object(humhub\modules\file\models\File))
#3 [internal function]: humhub\modules\file\commands\FileController->actionDownscaleImages()
#4 /humhub/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /humhub/protected/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#6 /humhub/protected/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction('downscale-image...', Array)
#7 /humhub/protected/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction('downscale-image...', Array)
#8 /humhub/protected/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction('file/downscale-...', Array)
#9 /humhub/protected/vendor/yiisoft/yii2/console/Application.php(148): yii\console\Application->runAction('file/downscale-...', Array)
#10 /humhub/protected/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest(Object(yii\console\Request))
#11 /humhub/protected/yii(29): yii\base\Application->run()
#12 {main}

J’ai donc modifié le fichier /etc/ImageMagick-6/policy.xml :

<policy domain="resource" name="disk" value="8GiB"/>

Humhub : runtime/searchdb/segments… is not readable.

How to fix the issue ?

It’s just necessary to rebuild index :

root@my:~# /usr/bin/php /var/www/humhub/protected/yii search/rebuild
Rebuild search index: ..........OK !
root@my:~# /usr/bin/php /var/www/humhub/protected/yii queue/run
root@my:~# /usr/bin/php /var/www/humhub/protected/yii cron/run 

Frédéric.

Humhub : Administration à faire

Voici les quelques actions que je fais …

Etape 1: Suppression du mode debug

Modification du fichier /var/www/humhub/index.php :

// comment out the following two lines when deployed to production
// defined('YII_DEBUG') or define('YII_DEBUG', true);
// defined('YII_ENV') or define('YII_ENV', 'dev');

Etape 2 : Upadate en ligne :

Mise à jours en ligne, quasiment pas de problème :
Mais j’ai du lancer la commande suite ensuite :

sudo chown -R www-data:www-data /var/www/humhub/

Etape 3 : Ajout de module PHP.

J’ai donc fait:

apt-get install php-sqlite3
apt-get install php-imagick
apt-get install imagemagick
apt-get install graphicsmagick libgraphicsmagick1-dev php-pear

Etape 4 : Les crons mise en place

* * * * * /usr/bin/php /var/www/humhub/protected/yii queue/run >/dev/null 2>&1
* * * * * /usr/bin/php /var/www/humhub/protected/yii cron/run >/dev/null 2>&1
0 1 * * * /usr/bin/mysqldump --defaults-extra-file=/home/XXXXX/.mylogin.cnf -u root --single-transaction --quick --lock-tables=false --all-databases > /mnt/backup/full-backup-$(date +\%F).sql
0 2 * * * rsync -zavh /var/www/humhub/ /mnt/backup/humback > /var/log/rsync.humhub.log

XXXXX = mon user.

Note 1 : Les fichiers images sont renommés il est donc imposible de faire un script pour faire de la compression d’image. C’est vraiment dommage.

# du -sh /var/www/humhub/uploads/file/0/1/019e636b-f43e-4442-9a8f-f0dce92dcf46/*
8,3M	/var/www/humhub/uploads/file/0/1/019e636b-f43e-4442-9a8f-f0dce92dcf46/file
112K	/var/www/humhub/uploads/file/0/1/019e636b-f43e-4442-9a8f-f0dce92dcf46/v3af9a23d