phpyoctovsftpd

How to enable the ftp module in php "Call to undefined function ftp_connect()"


I'm pretty new to Yocto, and I'm trying to call the ftp_connect() function within my php, but get an undefined function error.

I'm using Yocto Poky kirkstone (4.0.2) for corei7-64-poky-linux, and in my local.conf file I added the following:

IMAGE_INSTALL:append = " lighttpd lighttpd-module-fastcgi"
IMAGE_INSTALL:append = " vsftpd"
IMAGE_INSTALL:append = " php php-fpm"
PACKAGECONFIG[php] = " --enable-ftp --enable-debug "

I created a lighttpd_%.bbappend to customised lighttpd.conf with the right "server.document-root", "mod_fastcgi" and "fastcgi.server".

My webpage is loading and php 8.1.8 is working, but the ftp module is not loaded!

phpinfo() doesn't show the "--enable-ftp" option,

And no php.ini file is loaded:

Configuration File (php.ini) Path   /etc/php/apache2-php8
Loaded Configuration File   (none)

Why does it show apache2 when i'm using lighttpd? And why no ini file is loaded? And more importantly how do i enable ftp for PHP?

I tried to add apache2 to my local.conf, and adding "extension=ftp" using the following php_%.bbappend, but this didn't work either!

PHP_MAJOR_VERSION = "${@d.getVar('PV').split('.')[0]}"


do_install:append:class-target() {
    echo "extension=ftp" >>  ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}/php.ini  
}

I tried to add some debug line as follow but this didn't help:

error_reporting(E_ALL);
ini_set("display_errors", 1);
ini_set("log_errors", 1);  //
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );

Thanks in advance for your help, I've been trying for days now.


Solution

  • I'm not sure if it's the right way, but I finally managed to make it work.

    I just needed to add php-fpm in my local.conf

    IMAGE_INSTALL:append = " php-fpm"

    And to create a php_%.bbappend with the following:

    EXTRA_OECONF += " --enable-ftp"