synology php ftp_ssl_connect - Call to undefined function

不羁的心 提交于 2020-01-15 05:32:39

问题


First time asking a question here, please be gentle :-)

I'm writing a PHP command-line script on a Synology box to fetch files via ftps, and start out with this bit:

$ftp = ftp_ssl_connect("ftp.example.com");

When run from the command line, I get

Fatal error: Call to undefined function ftp_ssl_connect() in ...

phpinfo() tells me:

...
Registered PHP Streams => php, file, glob, data, http, ftp, https, ftps, zip, compress.zlib, compress.bzip2
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
...
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.1p-fips 9 Jul 2015
OpenSSL Header Version => OpenSSL 1.0.1p-fips 9 Jul 2015

and /etc/php/conf.d/extensions.ini contains extension = openssl.so (without an initial ;)

It seems to me that all the prerequisites for ftp_ssl_connect() are in place.

fwiw:

$ uname -a
Linux DiskStation01 2.6.32.12 #5644 Wed Oct 28 12:36:45 CST 2015 armv5tel GNU/Linux synology_88f6282_213

What would be the next place to look?


回答1:


Type php -m to see the compiled in modules, as PHP does not ship the FTP extension by default if not on Windows. Calling phpinfo() should also show the compiler switches used, and if they include --enable-ftp.

The curious thing is I just tried this on an RS812 of mine, and it shows both the FTP and OpenSSL moodules as included, and it works fine:

nas-name> php -r "ftp_ssl_connect('test');"
PHP Warning:  ftp_ssl_connect(): php_network_getaddresses: gethostbyname failed
in Command line code on line 1

This indicates the ftp_ssl_connect is working but not being able to parse the supplied host name. I have no idea why yours would be different unless you compiled PHP yourself.




回答2:


As mentioned in Niels solution the ftp-Module is missing in the default installation. I needed the module in the CLI version of PHP, but it was unavailable on all four of my Synology Devices (DS 412+, DS 410, RS812+ and RS814+).

Enabling the module in the Web Station settings did not help, but there is a solution for the CLI version in a Synology Forum Entry:

  1. make sure that the ftp extension is selected within php settings of Web Station.

  2. then edit /etc/php/php.ini to include a line like this:- extension = /volume1/@appstore/PHP5.6/usr/local/lib/php56/modules/ftp.so

  3. that's it. No restarting of Web Station or the NAS is required, as php loads itself from the commandline each time a call is made to php.



来源:https://stackoverflow.com/questions/34935997/synology-php-ftp-ssl-connect-call-to-undefined-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!