环境
- CentOS 7.4
- PHP 7.1.12 编译安装
复现
/usr/local/php71/bin/php -r "ftp_ssl_connect('server1.example.com');"
PHP Fatal error: Uncaught Error: Call to undefined function ftp_ssl_connect() in Command line code:1
|
原因
看文档:ftp_ssl_connect | php.net
- ftp 扩展没配置
- opensll 没有启用
解决方案
cd /root/php-7.1.12/ext/ftp/
/usr/local/php71/bin/phpize
./configure --with-php-config=/usr/local/php71/bin/php-config --with-openssl-dir
make make install
vim /usr/local/php71/lib/php.ini
extension=ftp.so
service php-fpm reload
|
这要注意一定要加上 --with-openssl-dir
,不然会 FTPS support => disabled
。
当不清楚 ./configure
有什么参数时,可以执行 ./configure --help
。
检查
/usr/local/php71/bin/php -r "phpinfo();" | grep FTP
FTP support => enabled FTPS support => enabled
/usr/local/php71/bin/php -r "ftp_ssl_connect('server1.example.com');"
PHP Warning: ftp_ssl_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in Command line code on line 1
|
References
– EOF –