http://doc.workerman.net/315116
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
解决办法:
pecl channel-update pecl.php.net
参考:https://blog.csdn.net/guo_qiangqiang/article/details/103586000
Warning: popen() has been disabled for security reasons in OS/Guess.php
警告:出于安全原因,popen()已经在OS/Guess.php中被禁用
Warning: popen() has been disabled for security reasons in OS/Guess.php on line 241
PHP Warning: popen() has been disabled for security reasons in /www/server/php/56/lib/php/OS/Guess.php on line 241
Warning: popen() has been disabled for security reasons in /www/server/php/56/lib/php/OS/Guess.php on line 241
Warning: fgets() expects parameter 1 to be resource, null given in OS/Guess.php on line 242
PHP Warning: fgets() expects parameter 1 to be resource, null given in /www/server/php/56/lib/php/OS/Guess.php on line 242
Warning: fgets() expects parameter 1 to be resource, null given in /www/server/php/56/lib/php/OS/Guess.php on line 242
Warning: pclose() expects parameter 1 to be resource, null given in OS/Guess.php on line 251
PHP Warning: pclose() expects parameter 1 to be resource, null given in /www/server/php/56/lib/php/OS/Guess.php on line 251
Warning: pclose() expects parameter 1 to be resource, null given in /www/server/php/56/lib/php/OS/Guess.php on line 251
Warning: readlink() has been disabled for security reasons in OS/Guess.php on line 257
PHP Warning: readlink() has been disabled for security reasons in /www/server/php/56/lib/php/OS/Guess.php on line 257
Warning: readlink() has been disabled for security reasons in /www/server/php/56/lib/php/OS/Guess.php on line 257
downloading event-2.5.6.tgz ...
Starting to download event-2.5.6.tgz (141,226 bytes)
..............................done: 141,226 bytes
50 source files, building
Warning: putenv() has been disabled for security reasons in PEAR/Builder.php on line 310
PHP Warning: putenv() has been disabled for security reasons in /www/server/php/56/lib/php/PEAR/Builder.php on line 310
Warning: putenv() has been disabled for security reasons in /www/server/php/56/lib/php/PEAR/Builder.php on line 310
running: phpize
Warning: popen() has been disabled for security reasons in PEAR/Builder.php on line 465
PHP Warning: popen() has been disabled for security reasons in /www/server/php/56/lib/php/PEAR/Builder.php on line 465
Warning: popen() has been disabled for security reasons in /www/server/php/56/lib/php/PEAR/Builder.php on line 465
ERROR: failed to run `phpize'
解决办法:
popen readlink putenv三个函数在php.ini里将popen函数禁用了
或者在这里添加
disable_functions中去掉对应三个函数,重启服务
参考:https://www.cnblogs.com/lxhyty/p/11237433.html
三个地方按上面来操作
注意目前libevent扩展不支持php7,php7用户只能使用Event扩展。
yum install libevent-devel
pecl install channel://pecl.php.net/libevent-0.1.0 //提示libevent installation [autodetect]: 时按回车
echo extension=libevent.so > /etc/php.d/libevent.ini
Title
注意:每次修改Workerman,都要重新启动
要启动Workerman,首先需要有一个启动入口文件,里面定义了服务监听的端口及协议。
可以参考入门指引--简单开发实例部分
server.php文件是自己写的php文件,路径放到项目中,
进入项目根目录后再命令启动
宝塔操作方法:
以debug(调试)方式启动
php
server.php start
以daemon(守护进程)方式启动
php
server.php start -d
php
server.php stop
php start.php restart
php
server.php reload
php
server.php status
由于安全原因,pcntl_fork()在第1515行文件/xxxxxx/vendor/workerman/workerman/Worker.php中被禁用
创建wss服务
问:
Workerman如何创建一个wss服务,使得客户端可以用过wss协来连接通讯,比如在微信小程序中连接服务端。
答:
wss协议实际是websocket+SSL,就是在websocket协议上加入SSL层,类似https(http+SSL)。 所以只需要在websocket协议的基础上开启SSL即可支持wss协议。
方法一 ,直接用Workerman开启SSL
准备工作:
1、Workerman版本不小于3.3.7
2、PHP安装了openssl扩展
3、已经申请了证书(pem/crt文件及key文件)放在磁盘任意目录
代码:
array(
// 请使用绝对路径
'local_cert' => '磁盘路径/server.pem', // 也可以是crt文件
'local_pk' => '磁盘路径/server.key',
'verify_peer' => false,
// 'allow_self_signed' => true, //如果是自签名证书需要开启此选项
)
);
// 这里设置的是websocket协议(端口任意,但是需要保证没被其它程序占用)
$worker = new Worker('websocket://0.0.0.0:443', $context);
// 设置transport开启ssl,websocket+ssl即wss
$worker->transport = 'ssl';
$worker->onMessage = function($con, $msg) {
$con->send('ok');
};
Worker::runAll();
参考:http://doc.workerman.net/faq/secure-websocket-server.html
在代码中配置对应SSL证书的路径:宝塔SSL证书路径/www/server/panel/vhost/ssl/www.xxx.com/