模块“ssh2”已经在第0行加载。

时间:2021-05-15 13:12:10

I use the functions below to copy files from one server to another. It works most of the time, but sometimes I start getting this error in log files:

我使用下面的函数将文件从一个服务器复制到另一个服务器。大多数情况下都是有效的,但有时我在日志文件中会发现这个错误:

Module 'ssh2' already loaded in Unknown on line 0

And it stops copying. Later for some reason, the error will stop and copying will start working again. What is the issue here?

它停止复制。由于某些原因,错误将停止,复制将重新开始工作。这里的问题是什么?

function getConn($server,$username,$password)
{
    $connection = 0;

    if (function_exists("ssh2_connect")) 
    {
        $connection = ssh2_connect($server, 3817);
        if($connection)
        {
            if(ssh2_auth_password($connection, $username, $password))
            {
                return $connection;
            }
        }
    }
    return 0;
}
function scp($server,$username,$password,$remotepath,$localpath)
{
    $connection = 0;
    $connection = $this->getConn($server,$username,$password);
    if($connection)
    {
        $ret = ssh2_scp_send($connection, $localpath, $remotepath, 0644);
        ssh2_exec($connection, 'exit'); 
    }
}

3 个解决方案

#1


10  

The error message Module 'ssh2' already loaded in Unknown on line 0 means that there's something off in your PHP configuration. Check to see if there's a line that says extension=ssh2.so in your php.ini. If so, remove it and check if everything is still working. Possibly, the extension=ssh2.so is loaded twice, meaning PHP will complain that the module is already loaded.

错误消息模块“ssh2”已经在第0行加载,这意味着在PHP配置中有一些问题。检查是否有一行表示扩展=ssh2。所以在你的php . ini。如果是这样,删除它并检查是否一切正常。可能扩展= ssh2。加载两次,意味着PHP将抱怨模块已经加载。

Good luck.

祝你好运。

#2


0  

In my case, I commented out the one line in ssh2.ini located here: /etc/php5/mods-available/ssh2.ini

在我的例子中,我注释掉了ssh2中的一行。ini位于:/etc/php5/mods-available / ssh2.ini

The content of this file now is as follow:

该文件的内容如下:

;extension=ssh2.so

Thanks!

谢谢!

#3


0  

If the above does not work, take a look inside /etc/php5/conf.d

如果上述方法无效,请查看/etc/php5/conf.d。

If you see duplicate ssh2.ini files, remove any extra ones.

如果你看到重复的ssh2。ini文件,删除多余的文件。

In my case I had 50-ssh2.ini and ss2.ini. Both files were providing the line:

在我的例子中,我有50-ssh2。ini ss2.ini。两个文件都提供了这一行:

extension=ssh2.so

For me removing 50-ssh2.ini solved the issue.

为我消除50-ssh2。ini解决了这个问题。

#1


10  

The error message Module 'ssh2' already loaded in Unknown on line 0 means that there's something off in your PHP configuration. Check to see if there's a line that says extension=ssh2.so in your php.ini. If so, remove it and check if everything is still working. Possibly, the extension=ssh2.so is loaded twice, meaning PHP will complain that the module is already loaded.

错误消息模块“ssh2”已经在第0行加载,这意味着在PHP配置中有一些问题。检查是否有一行表示扩展=ssh2。所以在你的php . ini。如果是这样,删除它并检查是否一切正常。可能扩展= ssh2。加载两次,意味着PHP将抱怨模块已经加载。

Good luck.

祝你好运。

#2


0  

In my case, I commented out the one line in ssh2.ini located here: /etc/php5/mods-available/ssh2.ini

在我的例子中,我注释掉了ssh2中的一行。ini位于:/etc/php5/mods-available / ssh2.ini

The content of this file now is as follow:

该文件的内容如下:

;extension=ssh2.so

Thanks!

谢谢!

#3


0  

If the above does not work, take a look inside /etc/php5/conf.d

如果上述方法无效,请查看/etc/php5/conf.d。

If you see duplicate ssh2.ini files, remove any extra ones.

如果你看到重复的ssh2。ini文件,删除多余的文件。

In my case I had 50-ssh2.ini and ss2.ini. Both files were providing the line:

在我的例子中,我有50-ssh2。ini ss2.ini。两个文件都提供了这一行:

extension=ssh2.so

For me removing 50-ssh2.ini solved the issue.

为我消除50-ssh2。ini解决了这个问题。