Php warning module ssh2 already loaded in unknown on line 0 ssh2

Предупреждение PHP: модуль ‘ssh2’ уже загружен в Unknown в строке 0

Эта машина работала отлично, но по какой-то причине я больше не могу удаленно выполнять сценарии bash на этом сервере.

Я могу подключиться через ssh2_exec без проблем, но когда я пытаюсь запустить скрипт bash, ничего не происходит.

if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); $connection = ssh2_connect('serverip.com', 22); ssh2_auth_password($connection, 'user', 'password'); $stream = ssh2_exec($connection, "/root/incoming/test.sh &> /dev/null &"); 

В этом случае test.sh просто вызывает wget для загрузки предопределенного файла.

wget -O /root/incoming/files/myfile.zip http://remoteserver.com/file.zip 

Когда я grep ssh2 локально на этой машине:

Я получаю ожидаемый результат:

Но когда я grep ssh2 удаленно, я получаю это:

PHP Warning: Module 'ssh2' already loaded in Unknown on line 0 ssh2 

Здесь я обнаружил следующий связанный с этим вопрос о том, что эта ошибка может быть вызвана тем, что расширение загружается дважды в конфигурационные файлы.

Итак, как и предполагалось, я проверил /etc/php5/apache2/php.ini — extension=ssh2.so не там, так что это не проблема.

Затем я последовал другому предложению и прокомментировал /etc/php5/mods-available/ssh2.ini :

Но теперь, когда я пытаюсь выполнить grep ssh2, модуль вообще не загружается. Есть ли где-нибудь еще, где я могу найти ssh2, потенциально дважды загруженную?

РЕДАКТИРОВАТЬ — я нашел файл с именем 20-ssh2.ini в /etc/php5/apache2/conf.d который загружал расширение снова и с тех пор удалил его, перезапустил apache, но все равно получил ошибку.

РЕДАКТИРОВАТЬ II — Просто понял, что файл выше воссоздается, когда я перезапустить Apache, это может быть проблемой?

Источник

Php warning module ssh2 already loaded in unknown on line 0 ssh2

Description: ------------ Installed every version of PHP from SVN/Snapshots: # php -m | grep ssh2 PHP Warning: Module 'ssh2' already loaded in Unknown on line 0 ssh2 When you remove extension=ssh2.so from the php.ini file: # php -m | grep ssh2 No modules are returned. The module is loaded only once in the config when the already loaded error message is returned. A find / -name "*" -print | xargs grep "ssh2.so" Returns the binary files in ~/ssh2-0.11.3 and /usr/local/php-5.3/lib/php/20090626/ as well as the /etc/php.ini file. Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini Scan this dir for additional .ini files => /etc Additional .ini files parsed => /etc/php.ini Only one file exists, and confirmed PHP is loading only one file. Backtrace did not result in any useful information. Test script: --------------- Any code, simply, php -v Expected result: ---------------- No message. Actual result: -------------- PHP Warning: Module 'ssh2' already loaded in Unknown on line 0

Patches

Pull Requests

History

Was able to resolve the issue by correcting the configuration: Old configure: './configure' '--prefix=/usr/local/php-5.3' '--enable-fastcgi' '--enable-cgi' '--enable-cli' '--disable-debug' '--disable-rpath' '--disable-static' '--with-pic' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-ctype' '--with-curl' '--with-zlib-dir=/usr' '--with-xsl' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--with-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-gettext' '--with-iconv' '--with-imap-ssl' '--with-kerberos=/usr' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mime-magic' '--with-mysql=/usr/local/mysql-5.5' '--with-pcre-regex=/usr' '--with-pspell=/usr' '--enable-sockets' '--enable-wddx' '--with-xmlrpc' '--with-zlib=/usr' '--with-pear' '--with-layout=GNU' '--with-ldap' '--enable-pdo' '--enable-soap' '--with-apxs2=/usr/local/apache-2.2/bin/apxs' '--enable-pcntl' '--enable-mailparse' '--enable-zip' '--with-zip=/usr' '--with-bz2=/usr' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc' '--with-pdo-mysql=/usr/local/mysql-5.5' '--enable-zip' '--with-snmp' '--with-mysqli=/usr/local/mysql-5.5/bin/mysql_config' '--with-phar' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-tidy' '--with-openssl=/usr/local/ssl' '--enable-phar' New Configure: './configure' '--prefix=/usr/local/php-5.3' '--enable-fastcgi' '--enable-cgi' '--enable-cli' '--disable-debug' '--disable-rpath' '--disable-static' '--with-pic' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-ctype' '--with-curl' '--with-zlib-dir=/usr' '--with-xsl' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--with-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-gettext' '--with-iconv' '--with-imap-ssl' '--with-kerberos=/usr' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mime-magic' '--with-mysql=/usr/local/mysql-5.5' '--with-pcre-regex=/usr' '--with-pspell=/usr' '--enable-sockets' '--enable-wddx' '--with-xmlrpc' '--with-zlib=/usr' '--with-pear' '--with-layout=GNU' '--with-ldap' '--enable-pdo' '--enable-soap' '--with-apxs2=/usr/local/apache-2.2/bin/apxs' '--enable-pcntl' '--enable-mailparse' '--enable-zip' '--with-zip=/usr' '--with-bz2=/usr' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/usr/local/php-5.3/etc' '--with-pdo-mysql=/usr/local/mysql-5.5' '--enable-zip' '--with-snmp' '--with-mysqli=/usr/local/mysql-5.5/bin/mysql_config' '--with-phar' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-tidy' '--with-openssl=/usr/local/ssl' '--enable-phar' An emphisis should be placed on the differences in: '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc' vs '--with-config-file-path=/etc' '--with-config-file-scan-dir=/usr/local/php-5.3/etc' If the same path is used in both locations, it will load the php.ini twice, causing the error.
Personally, PHP should grab an MD5 of the ini's and if different, then load them, so it doesn't load the same config +1 time. Closing bug.

Источник

PHP not loading ssh2 extension after successful installation

I was getting this error, when running my PHP script to download files using SFTP: PHP Fatal error: Call to undefined function ssh2_connect() I installed the ssh2 PECL extension by running the below commands

 sudo pecl channel-update pecl.php.net sudo apt-get install libssh2-1-dev sudo pecl install -a ssh2-0.12 echo 'extension=ssh2.so' | sudo tee /etc/php5/mods-available/ssh2.ini > /dev/null sudo php5enmod ssh2 

I updated the php.ini files. When I view the output of phpinfo(), I can see ssh2 as enabled. The PHP extensions directory is /usr/lib/php5/20121212 where I can see the file ssh2.so. However when I run the below command to see the extensions loaded by PHP, I can’t find ssh2 and therefore getting the same fatal error

 user84@Perseus2:~$ php --ini Configuration File (php.ini) Path: /etc Loaded Configuration File: /etc/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) user84@Perseus2:~$ php5 --ini PHP Warning: Module 'ssh2' already loaded in Unknown on line 0 Configuration File (php.ini) Path: /etc/php5/cli Loaded Configuration File: /etc/php5/cli/php.ini Scan for additional .ini files in: /etc/php5/cli/conf.d Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini, /etc/php5/cli/conf.d/10-pdo.ini, /etc/php5/cli/conf.d/20-curl.ini, /etc/php5/cli/conf.d/20-gd.ini, /etc/php5/cli/conf.d/20-json.ini, /etc/php5/cli/conf.d/20-mysql.ini, /etc/php5/cli/conf.d/20-mysqli.ini, /etc/php5/cli/conf.d/20-pdo_mysql.ini, /etc/php5/cli/conf.d/20-pdo_pgsql.ini, /etc/php5/cli/conf.d/20-pgsql.ini, /etc/php5/cli/conf.d/20-readline.ini, /etc/php5/cli/conf.d/20-ssh2.ini 

I can see other extensions for php5 installed e.g. openssl, but when I lookup ssh2, nothing shows up.

 user84@Perseus2:/etc/php5/cli$ php --ri ssh2 Extension 'ssh2' not present. user84@Perseus2:/etc/php5/cli$ php --ri openssl openssl OpenSSL support => enabled OpenSSL Library Version => OpenSSL 1.0.1f 6 Jan 2014 OpenSSL Header Version => OpenSSL 1.0.1f 6 Jan 2014 

Источник

Модуль ‘ssh2’ уже загружен в Unknown в строке 0

Я использую функции ниже для копирования файлов с одного сервера на другой. Это работает большую часть времени, но иногда я начинаю получать эту ошибку в файлах журнала:

Module 'ssh2' already loaded in Unknown on line 0 

И это перестает копировать. Позже по какой-то причине ошибка прекратится, и копирование снова начнет работать. В чем здесь проблема?

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 ответа

Сообщение об ошибке Module ‘ssh2’ already loaded in Unknown on line 0 означает, что что-то не так в вашей конфигурации PHP. Проверьте, есть ли строка, которая говорит extension=ssh2.so в вашем php.ini. Если это так, удалите его и проверьте, все ли еще работает. Возможно, расширение = ssh2.so загружается дважды, то есть PHP будет жаловаться, что модуль уже загружен.

В моем случае я закомментировал одну строку в ssh2.ini находится здесь: /etc/php5/mods-available/ssh2.ini

Содержимое этого файла теперь выглядит следующим образом:

Если вышеперечисленное не работает, загляните внутрь /etc/php5/conf.d

Если вы видите дубликаты файлов ssh2.ini, удалите все лишние.

В моем случае у меня были 50-ssh2.ini и ss2.ini. Оба файла содержали строку:

Для меня удаление 50-ssh2.ini решило проблему.

Источник

Читайте также:  Elementtree python 3 установить
Оцените статью