This guide shows how to enable extensions in PHP CLI (command line interface).
Check your php ini location
php --ini
Change to the folder to where the php.ini is located given by the previous command which was in my case
/usr/local/etc/php70/php.ini
Use vi to edit the file
sudo vi php.ini
Change the extension dir path in php.ini to /volume1/@appstore/PHP7.0/usr/local/lib/php70/modules. Depending on your PHP version the location might differ.
Enable the extension by adding the following code line to your php.ini. Here’s an example showing how to enable PDO_mysql support.
extension = pdo_mysql.so
I had to the correct php executable. In my case it was located under
/volume1/@appstore/PHP7.0/usr/local/bin
There is no restart of any kind necessary to make this work as php.ini is initialised on every start when using PHP CLI. If you want to enable the extension on your webserver you have to to use the DSM settings for webstation to do it.
Hi,
I read your post concerning enabling pdo_mysql extension, because I have serious problems with enabling PDO with php5.6. Every time I get the error that driver could not be found.
I have a DS411 with DSM 6.x installed, running apache2.2, php5.6, mariadb10 and web station.
I followed your guide. Found via php -m the path where php.ini is located (the location differs however from the location phpinfo() shows…).
Changed the extensiondir_path and added pro_mysql.so.
I don’t know how to correct the php executable.
When I do ‘php -m’ all the loaded php modules are shown. I can see PDO among them, but no pdo_mysql.
It’s all very confusing and frustrating.
Is there a chance you can help me?
Thanks,
Sece
There are usually multiple php.ini. The PHP CLI uses a different one than the webservice. Did you try the command line “php –ini” to see which one PHP CLI is using? Btw. PHP package update seems to overwrite the ini file used by the CLI. I usually run CLI in a location similar to this “/volume1/@appstore/PHP7.0/usr/local/bin” as this seemed to matter aswell.
Whe I try “php -ini” I get the phpinfo() which tells me the version used: 5.6.11 That differs from the version I get from the web service : 5.6.40
I didn’t know there are different versions.
This is the first part of phpinfo():
Build Date => Apr 20 2017 02:51:16
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php
Loaded Configuration File => /etc/php/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20131106
PHP Extension => 20131226
Zend Extension => 220131226
Zend Extension Build => API220131226,NTS
PHP Extension Build => API20131226,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => compress.zlib, php, file, glob, data, http, ftp
Registered Stream Socket Transports => tcp, udp, unix, udg
Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
In the ‘CORE’ part of this phpinfo() I see this line you mentioned in your guide:
extension_dir => /usr/local/lib/php56/modules => /usr/local/lib/php56/modules
When I do php –ini I get:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php56/modules/pdo_mysql.so’ – /usr/local/lib/php56/modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Configuration File (php.ini) Path: /etc/php
Loaded Configuration File: /etc/php/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Somehow I have to change some settings, but I do not have any clue what and where to change.
Are the extensios really there in that directory? I had PHP version with an empty extensions directory. There are as well multiple of those.
I have put them in that directory myself. I’ve read somewhere on the web the suggestion to put them there. But this is wrong, I assume?
Please can you tell me what to do?
And “pdo_mysql.so” is located in “/usr/local/lib/php56/modules/”?
No, I don’t have/can’t find “pdo_mysql.so”.
Only “pdo_sqlite.so” and “sqlite3.so” are in this directory.
If your webserver is running check php-info() there to see which directory is used for the modules. Put the extension-dir path to that directory. I think I’m using “/volume1/@appstore/PHP7.0/usr/local/lib/php70/modules/” and double check that the PDO extension is listed there.
I will see to that tomorrow. At the moment I must leave. I hope I can come back to you tomorrow? For now, I thank you for your suggestions. I will let you know my progress.
Gr. Sece
On this place: /volume1/@appstore/WebStation/misc/WebStation-php56/conf.d$ I found the file: ‘extension.ini’ with all the extensions I think will need, including ‘pdo_mysql.so’
According to phpinfo() the extension_dir path is ‘/usr/local/lib/php56/modules’ So I copied the ‘extension.ini’ to this extension_dir path.
Now what? Should I restart Apache? Or Web Station? Can I do that with the CLI? If so, which command to restart?
You need to copy the pdo_mysql.so to the modules. directory. And as I said before, if you call phpinfo() via web browser, you will see the PHP configuration for the webserver not CLI.
pdo_mysql.so is inside the extension.ini file.
How do I get pdo_mysql.so out of extension.ini and place it in the modules directory?
It’s not, maybe listed there. You habe to search for the file itself “pdo_mysql.so”.
“pdo_mysql.so” is only found in the file ‘extension.ini’, not as a file on its own however…
Well then you have to find it in another PHP modules folder. There is more than one. The webservers module folder should contain all the modules *.so.
Searching the whole system with ‘grep -ir “*.so” / ‘ or ‘grep -ir “pdo_mysql.so” /’ gives no result. It seems to me this file does not exist on my synology? Can I install this file somehow?
If you can enable them via webstation ui -> PHP they should be on the system somewhere.
Finally found them. There are a bunch of SO files in this location:
/volume1/@appstore/PHP5.6/usr/local/lib/php56/modules
Now I have changed in all the php.ini files I could find the extension_dir path to /volume1/@appstore/PHP5.6/usr/local/lib/php56/modules.
But…. no result.
I cannot believe Synology has made this so complicated. IMHO it should work out of the box.
Did you run php56/php70 executables at the correct location as this seems to matter aswell.
I don’t know how to run these executables. Can you tell me how?
I did not run the executables because I don’t know how. Can you tell me please?
Well I do it like that…
“/volume1/@appstore/PHP7.0/usr/local/bin/php70 /path/to/yourfile.php” where php70 is the executable.
No success…
I’m gone delete all web and php related stuff from my synology and start all over.
Thank you for your suggestions and advise.
Gr. Sece