Reputation: 204
I'm trying to execute a php script via command line on my synology NAS. Via web browser it's working fine. However, via CLI I'm getting an error although I loaded the extensions in /etc/php/php.ini
.
Fatal error: Uncaught PDOException: could not find driver in /volume1/web/blabla.php:16
Any ideas?
Upvotes: 5
Views: 11193
Reputation: 2424
Synology uses two different php intallations. One for the internal issues (like administrator panel) and the other from the package you've installed for the web server.
you can observe the differences running from command line:
php --ini
php56 --ini
php7 --ini
(depending of the php package installed)
use php56 or php7 to run your script
Update
Please use the following for more recent versions of PHP (assuming both are installed)
php72 --ini
php74 --ini
Upvotes: 7
Reputation: 2121
for me (DSM 6.1.6-15266 Update 1) the following helped:
Add the following lines to /usr/local/etc/php70/php.ini
extension = pdo_mysql.so
extension = openssl.so
I struggled very long to get the correct values, finally I found them by comparing to the config files of the php56 instance.
Upvotes: 0
Reputation: 1480
I was in the same boat–trying to get PHP 7.0 to work on the command-line of my Synology DiskStation DS218+.
I typed php70 --ini
and I found out that PHP was using an INI file located at /usr/local/etc/php70/php.ini
.
I went to the directory
cd /usr/local/etc/php70/
Made a backup of the .ini
file just incase.
sudo cp php.ini php.ini.bak
Opened vi
.
sudo vi php.ini
Hit i
to enter Insert
mode. I changed from this:
extension_dir = "/usr/local/lib/php70/modules"
to this:
extension_dir = "/volume1/@appstore/PHP7.0/usr/local/lib/php70/modules"
I also added this line:
extension = pdo_mysql.so
I then hit Esc
, followed by :
then wq
and . This leaves insert mode, writes the .ini
to disk, and quits.
That's it! After that, I was able to run command-line scripts by invoking php70
followed by the script name.
Upvotes: 2
Reputation: 204
Just make sure to use the correct PHP version and PHP.ini. You can find the location of your php.ini by typing "php --ini". You can also do that on the executables php56/php70. They all have separate php.ini files. Additionaly make sure to load the correct extension directory in the applicable php.ini file.
Upvotes: 1
Reputation: 33
Did you try: php56 path/to/script.php or php70 path/to/script.php ? If I'm not wrong, /etc/php/php.ini is for DSM engine... For symfony, I use php56 bin/console command. php or php70 doesn't work for me (DSM 6.1.3 on DS415+) Hope it helps !
Upvotes: -1