Fatal error: Call to undefined function ftp_ssl_connect()

后端 未结 2 1497
逝去的感伤
逝去的感伤 2021-01-24 02:24

I am trying to set up FTP SSL connection in PHP. I have used ftp_connect() fine and works great. As soon as I try to use ftp_ssl_connect(), I get thi

2条回答
  •  滥情空心
    2021-01-24 02:36

    PHP7.1.12 CentOS

    I build php by myself.

    /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
    

    resolve:

    # /root/php-7.1.12/ is php source dir
    cd /root/php-7.1.12/ext/ftp/
    
    # /usr/local/php71/ is php dir
    /usr/local/php71/bin/phpize
    
    # the param --with-openssl-dir is very important
    ./configure --with-php-config=/usr/local/php71/bin/php-config --with-openssl-dir
    
    make
    make install
    
    vim /usr/local/php71/lib/php.ini
    # add last line
    extension=ftp.so
    
    service php-fpm reload
    

    check:

    # method 1
    /usr/local/php71/bin/php -r "phpinfo();" | grep FTP
    
    FTP support => enabled
    FTPS support => enabled
    
    # method 2
    /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
    

    done!

提交回复
热议问题