synology php ftp_ssl_connect - Call to undefined f

2019-07-16 10:42发布

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?

标签: php ssl synology
2条回答
SAY GOODBYE
2楼-- · 2019-07-16 10:50

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.

查看更多
叼着烟拽天下
3楼-- · 2019-07-16 11:06

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.

查看更多
登录 后发表回答