lixuancn / MeepoPS

MeepoPS是Meepo PHP Socket的缩写,旨在提供稳定的Socket服务。可以轻松构建在线实时聊天、即时游戏、视频流媒体播放等。
http://meepops.lanecn.com
Do What The F*ck You Want To Public License
505 stars 137 forks source link

PHP Fatal error: Uncaught Error: Call to undefined function ssh2_connect() #4

Closed Tinywan closed 7 years ago

Tinywan commented 7 years ago

你好!

当浏览器输入http://127.0.0.1:19911/ 访问的时候服务端报错,

$ sudo php real_time_monitor_ssh_server.php restart
[INFO][2017-04-29 23:24:45][74344]MeepoPS receives the "restart" instruction, MeepoPS will graceful restart
MeepoPS Stop:                          [OK]
MeepoPS Start:                         [OK]
-------------------------- MeepoPS Start Success ------------------------
MeepoPS Version: 0.0.5 | PHP Version: 7.0.15-0ubuntu0.16.04.4 | Master Pid: 74344 | Event: Select
-------------------------- Instances List -------------------------
MeepoPS-WebSocket  websocket://0.0.0.0:19910  Child Process: 1
MeepoPS-Http  http://0.0.0.0:19911  Child Process: 1

PHP Fatal error:  Uncaught Error: Call to undefined function ssh2_connect() in /home/tinywan/MeepoPS/Example/Real_Time_Monitor_Ssh/websocket_server.php:58
Stack trace:
#0 /home/tinywan/MeepoPS/Example/Real_Time_Monitor_Ssh/websocket_server.php(40): _connectServer(Object(MeepoPS\Core\TransportProtocol\Tcp), '127.0.0.1', 'root', '123456')
#1 /home/tinywan/MeepoPS/Example/Real_Time_Monitor_Ssh/websocket_server.php(29): memfree(Object(MeepoPS\Core\TransportProtocol\Tcp), Array)

浏览器没有数据:

qq 20170429232919

lixuancn commented 7 years ago

这个实例是用ssh2的方式实现的,就是说用代码模拟ssh2登录到待监控的机器,在该机器上执行一些命令,你可以不这么做,换一种方式,比如接收客户端发来的打点数据。

ssh2_connect是系统函数,需要安装PHP扩展ssh2才可以:http://php.net/manual/en/function.ssh2-connect.php

Tinywan commented 7 years ago

@lixuancn 谢谢!

-- 解压 tar -xvf ssh2-1.0.tgz

-- 复制目录到指定位置 sudo cp ssh2-1.0 -R /usr/bin/

-- 进入指定目录 cd /usr/bin/ssh2-1.0/

-- 扩展模块 sudo phpize

-- 检查配置文件 sudo ./configure --with-ssh2

-- 编译 sudo make

--安装 sudo make install

--查看安装情况 cd /usr/lib/php/20151012/

-- 修改配置文件 sudo vim /etc/php/7.0/cli/php.ini

-- 添加以下内容 extension=/usr/lib/php/20151012/ssh2.so

-- 查看模块是否安装成功 php -m | grep ssh2 ssh2

-- 安装结束


+  效果图显示
![qq 20170503235207](https://cloud.githubusercontent.com/assets/14959876/25669275/9ff5a2b2-305b-11e7-878e-be80a46663ee.png)
lixuancn commented 7 years ago

你所说的PHP7只能使用1.0版本是说ssh2-1.0还是MeepoPS1.0?如果是MeepoPS的话烦请告知那里报错了?

Tinywan commented 7 years ago

@lixuancn 你好! 是 ssh2-1.0