Php SSH2连接opendir在centos7上不工作

Php SSH2连接opendir在centos7上不工作,php,centos7,libssh2,ssh2-sftp,Php,Centos7,Libssh2,Ssh2 Sftp,我已将我的本地代码上载到新服务器上。服务器是Centos 7,带有PHP5.6.31和PHP5.5.28 我在两个php版本上都安装了ssh2 connect库。 我正在尝试使用以下代码连接到其他服务器 if (!function_exists("ssh2_connect")) die('Function ssh2_connect not found, you cannot use ssh2 here'); if (!$connection = ssh2_connect($schema[

我已将我的本地代码上载到新服务器上。服务器是Centos 7,带有PHP5.6.31和PHP5.5.28

我在两个php版本上都安装了ssh2 connect库。 我正在尝试使用以下代码连接到其他服务器

if (!function_exists("ssh2_connect"))
    die('Function ssh2_connect not found, you cannot use ssh2 here');
if (!$connection = ssh2_connect($schema['conn']['host'], $schema['conn']['port']))
    die('Unable to connect');
if (!ssh2_auth_password($schema['conn']['connection'], $schema['conn']['username'], $schema['conn']['password']))
    die('Unable to authenticate.');
if (!$stream = ssh2_sftp($schema['conn']['connection']))
    die('Unable to create a stream.');
if (!$dir = opendir('ssh2.sftp://'.intval($stream).$remoteDirPath))
    die('Could not open the directory');
我的代码一直运行良好

  if (!$stream = ssh2_sftp($schema['conn']['connection']))
    die('Unable to create a stream.');
之后,我得到“无法打开目录”错误。 这段代码在我的本地计算机中运行良好


有人能帮我解决这个问题吗?如果需要更多信息,请告诉我。

美元的价值是多少?它存在吗?是的,它是我的远程目录路径ex./home/test/file,包括文件名吗?或者它是目录的名称?它的目录。不是文件名。此文件夹中有许多文件需要处理。所以我们只是检查一下目录,然后深入查找文件。我看不出有什么问题。也许可以试试关于使用
ls
的最后一句话。但这与其说是一个解决方案,不如说是一个解决方案,来解释为什么它不起作用