Non classé, Self-hosting

How to fix PHP 7 bash error to update Nextcloud on Synology?

PHP 7 is mandatory since Nextcloud 14

If you tried to update Nextcloud to Synology from the console, you probably had to run into an error when you needed to run PHP.

Synology made it the hard way for the users : the “php” bash function has been replaced by “php56” (dunno why…).

If you read this carefully, your reflexe will be to use php70 instead of php, when executing php 7 command…or not! with sudo -u http php70… for example you’ll get an error. And update Nextcloud since version 14 is impossible with php 5.6.

What we need here is to create a script we can call every time we need to exectute a php 7 command (still in bash) and pass the error


Let’s assume that you have installed the PHP 5.6 and PHP 7 packages, and therefore a php 5.6 profile and a php 7 profile.

To start, we will have to locate the php 7 profile we will use: log in SSH to your server, and go to /var/packages/WebStation/etc/php_profile

You should have 2 folders with very complex names (a7557633-8e25-4a6a-83cd-7dc6fb38e783 for example). Edit the fpm.conf file.

Now you can see the syslog.ident = php70-fpm line which indicate you are on the right profile (The php 5.6 profile has obviously syslog.ident = php56-fpm). Write down the character string corresponding to the name of the profile, then proceed to script creation:

Script creation

php70 $*

Replace the-profile-name by… the character string you noted before, then save the file giving the name for example, and drop it to your server.

You can also do it into the console

echo -e '#!/bin/bash\n PHP_INI_SCAN_DIR=.:/usr/local/etc/php70/:/var/packages/WebStation/etc/php_profile/the-profile-name/conf.d/\n export PHP_INI_SCAN_DIR\n php70 $*' > /volume1/web/scripts/

Now you can replace php in all your commands by ./

For example to update Nextcloud  :

sudo -u http ./ occ upgrade

Create an alias

To avoid remembering the script path whenever you need it, let’s create an alias:

In the file /etc.defaults/.bashrc_profile, let’s add the line:

alias php-7='/path/to/the/script/'

I chose php-7 for my alias (but you can chose everything you want). You can now relog to your server in SSH, and use php-7 to run your php7 commands.

We finally have all the elements to serenely begin the update of Nextcloud: I will detail all this in a future article! 🙂

Thanks Andreas from Viking Studios for the tip!

Leave a Reply

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