PHP 7 on Synology

I’m trying to update my synolgy web station from PHP 5.6 to PHP 7.0, but I get errors. The web interface seems to work ok, but calling cron.php gives this result:
The command executed by synology’s “task planner” is
su -s /bin/sh -c “/usr/local/bin/php70 -f /var/services/web/nextcloud/cron.php” http
the result is
PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /volume1/web/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Ob in /volume1/web/nextcloud/lib/private/DB/Connection.php on line 64
PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /volume1/web/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Ob in /volume1/web/nextcloud/lib/private/DB/Connection.php on line 64

for
su -s /bin/sh -c “/usr/local/bin/php56 -f /var/services/web/nextcloud/cron.php” http
I get no result → everything works. So it seems something is missing in my php 7.0 setup - what could that be?

Check if you run the cronjob with an user of apache/nginx. Should be www-data or something like that :wink:

The user in Synology is http. That’s the last word in my cron command.

Did you changed in the cronjob command using with php 7.0?

yes, the command not working is /usr/local/bin/php70

It used to work for me with php56 on my DiskStation but that broke as well.

I figured out what to do:

cp  /usr/syno/etc/packages/WebStation/php70/php.ini .
cat /usr/syno/etc/packages/WebStation/php_profile/SOME-UUID/conf.d/user_settings.ini >> php.ini

set the extension_dir in the new php.ini like this:

extension_dir = /volume1/@appstore/PHP7.0/usr/local/lib/php70/modules

Now occ works again:

sudo -u http php70 -c php.ini occ maintenance:mode --on
Cannot load Zend OPcache - it was already loaded
Maintenance mode enabled
1 Like

Thank you for your suggestion!

The two commands (cp and cat) are executed in a certain directory. I think it’s important which directory that would be.

The directory isn’t important as it would create the php.ini in your current working directory.

If you execute the occ command you need to add the -c argument with a relative or absolute path to the php.ini you just created.

If I remember it correctly, in the end I had the php.ini one folder above the occ script:

sudo -u http php70 -c php.ini nextcloud/occ maintenance:mode --off
pwd
   /volume1/web

TL:DR: it’s your choice :wink:

This totally helped me - saved me several days of WTF - and had not seen anything descriving this behavior in any documentation anywhere. And I have installed Nextcloud on at least 4 different desktop systems, ARMHF, and AWS - thanks so much!

OMG, now I got it… (I read your post once or twice and didn’t understand. Bad english :frowning:. mep’s post made me reread it.)

I think I got it working now. There is a message about a missing mysql library, but Nextcloud doesn’t complain, so let’s cross fingers. :crossed_fingers:

Sorry about my English. I’m not sure about the MySQL library, I think that was why I had to edit the extension_dir option in the resulting php.ini. Also make sure, that the options extension = mysqli.so and extension = pdo_mysql.so are present. This entries come form the file /usr/syno/etc/packages/WebStation/php_profile/SOME-UUID/conf.d/user_settings.ini in step 2 of creating the custom php.ini file - warning: you need to replace SOME-UUID with a value that works for your installation!

Oh no, you got it wrong. I was complaining about MY bad english. Sorry that you misunderstood my meagre words.

Thank you for your advice, I will check this evening.

I checked the options in php.ini, but they were correct. But then I tried the other user in php_profile (there are two in my system) and that did the trick!
And then I compared the two user_settings.ini and found that one was missing the extension=mysql.so, so I didn’t look thoroughly when I tried to spot the error…

Now I still get a warning
PHP Warning: PHP Startup: No such handler: DBA_DEFAULT in Unknown on line 0
but then it says
Maintenance mode disabled
so that seems to be only a warning.

Thank you for your help again!

Sorry, another detail is the full path to the ini file which I kept a directory above.

Give that you are pretty handy with Nextcloud and if I understand correctly you have a Synology. Do you know of any resource to get the NextcloudPi docker image/container running on a 918+ - I can’t seem to get the right set of configuration with the docker run, and freeing up or configuring the 80/443 port without conflicting with the system and its really upsetting me.

I have a DS214+ so no docker for me :disappointed:

The nginx config from Synology is hard to work with and I had to fight to get Nextcloud that was originally installed as ownCloud app form the community repo to work on 80 and 443 for IPv4 and IPv6. To be honest I didn’t test if IPv6 still works - it is very brittle beginning with my ADSL-Modem needing reboots if the firewall starts to block IPv6 again.

So I wrote this up in another topic, but I basically answered my questions.

DOMAIN=192.168.1.96

docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 --ip-range=192.168.1.96/27 -o parent=eth0 bridged_lan

docker run -d --network=bridged_lan --ip=192.168.1.96 -p 4443:4443 -p 443:443 -p 80:80 -v /volume1/docker/nextcloudplus :/data --name nextcloudplus ownyourbits/nextcloudpi-x86 $DOMAIN

Basically uses docker to create a virtual IP address from its internal DHCP server and a LAMP stack is created, tada! No messing around with nginx, or files, or UI.

The first thing I did with Synology was chroot it and install my normal stack, this should be the 3rd thing I do, instead of wasting time figuring out what goes where with the system.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.