[root@VM_0_15_centos im]# php -v
PHP 7.2.14 (cli) (built: Jan 29 2019 12:00:38) ( NTS )
php扩展:
[root@VM_0_15_centos im]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
swoole
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zlib
[root@VM_0_15_centos im]# php --ri swoole
swoole
swoole support => enabled
Version => 2.0.8
Author => tianfeng.han[email: [email protected]]
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
[root@VM_0_15_centos im]# ls
App composer.lock Config.php easyswoole.install index.php makefile RedisKeys.txt Temp
composer.json Conf EasySwooleEvent.php img Log README.md talk.sql vendor
<?php
/**
* Created by PhpStorm.
* User: yf
* Date: 2017/12/30
* Time: 下午10:59
*/
return [
'MAIN_SERVER'=>[
'HOST'=>'0.0.0.0',
'PORT'=>9501,
'SERVER_TYPE'=>\EasySwoole\Core\Swoole\ServerManager::TYPE_WEB_SOCKET_SERVER,
'SOCK_TYPE'=>SWOOLE_TCP,//该配置项当为SERVER_TYPE值为TYPE_SERVER时有效
'RUN_MODEL'=>SWOOLE_PROCESS,
'SETTING'=>[
'task_worker_num' => 2, //异步任务进程
'task_max_request'=>10,
'max_request'=>2500,//强烈建议设置此配置项
'worker_num'=>2,
'document_root' => '/website/swoole-im/Public', // 静态资源目录
'enable_static_handler' => true,
// 'heartbeat_idle_time' => 60,
// 'heartbeat_check_interval' => 20,
],
],
'DEBUG'=>true,
'TEMP_DIR'=>EASYSWOOLE_ROOT.'/Temp',
'LOG_DIR'=>EASYSWOOLE_ROOT.'/Log',
'EASY_CACHE'=>[
'PROCESS_NUM'=>3,//若不希望开启,则设置为0
'PERSISTENT_TIME'=>5//如果需要定时数据落地,请设置对应的时间周期,单位为秒
],
'CLUSTER'=>[
'enable'=>false,
'token'=>null,
'broadcastAddress'=>['255.255.255.255:9556'],
'listenAddress'=>'0.0.0.0',
'listenPort'=>9556,
'broadcastTTL'=>5,
'serviceTTL'=>10,
'serverName'=>'easySwoole',
'serverId'=>null
],
'MYSQL'=>[
'HOST'=>'隐藏一下',
'USER'=>'隐藏一下',
'PASSWORD'=>'隐藏一下',
'DB_NAME'=>'talk'
],
'REDIS' => [
'host' => '隐藏一下', // redis主机地址
'port' => 6379, // 端口
'serialize' => false, // 是否序列化php变量
'auth' => '隐藏一下', // 密码
'pool' => [
'min' => 5, // 最小连接数
'max' => 100 // 最大连接数
],
'errorHandler' => function(){
return null;
}
],
'database' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '隐藏一下',
// 数据库名
'database' => 'talk',
// 用户名
'username' => '隐藏一下',
// 密码
'password' => '隐藏一下',
// 端口
'hostport' => '3306',
// 数据库表前缀
'prefix' => '',
// 是否需要断线重连
'break_reconnect' => true,
],
'setting' => [
'token_salt' => 'gye76qwei23eq',
'WebSocketControllerPath' => 'App\WebsocketController\\',
'cache_name' => [
'token_user' => 'user:token:%s:data', // token => user 信息, 用户登录时创建
'number_userOtherInfo' =>'userOtherInfo:%s:number:data', // number => fd,token 等信息,用户登录时创建
'fd_token' => 'fd:%s:data', // fd => token, 用户登录时创建
'friend_req' => 'friend:fromNumber:%s:data', // from_num => to_num,发送好友请求时创建,对方拒绝或同意时销毁
'group_number_fd' => 'group:number:%s:data', // gnumber => fds,创建新群组时创建
],
]
];
server{
listen 80;
server_name im.itsideline.com;
location / {
root /home/www/im;
index index.html index.htm index.php;
if (!-e $request_filename) {
proxy_pass http://127.0.0.1:9501;
}
}
}
[root@VM_0_15_centos im]# php index.php start
______ _____ _
| ____| / ____| | |
| |__ __ _ ___ _ _ | (___ __ __ ___ ___ | | ___
| __| / _` | / __| | | | | \___ \ \ \ /\ / / / _ \ / _ \ | | / _ \
| |____ | (_| | \__ \ | |_| | ____) | \ V V / | (_) | | (_) | | | | __/
|______| \__,_| |___/ \__, | |_____/ \_/\_/ \___/ \___/ |_| \___|
__/ |
|___/
EasySwoole framework Version 2.0.2
listen address 0.0.0.0
listen port 9501
worker num 2
task worker num 2
run at user root
daemonize false
debug enable true
swoole version 2.0.8
swoole pid 21696
loading data from file at process easySwoole_Cache_Process_0
loading data from file success at process easySwoole_Cache_Process_0
loading data from file at process easySwoole_Cache_Process_1
loading data from file success at process easySwoole_Cache_Process_1
loading data from file at process easySwoole_Cache_Process_2
loading data from file success at process easySwoole_Cache_Process_2
PHP Fatal error: Uncaught Error: Call to a member function getObj() on null in /home/www/im/App/Service/RedisPoolService.php:23
Stack trace:
#0 /home/www/im/App/Service/UserCacheService.php(142): App\Service\RedisPoolService->__construct()
#1 /home/www/im/App/Sock/Parser/OnClose.php(80): App\Service\UserCacheService::getTokenByFd(1)
#2 /home/www/im/App/Sock/Parser/OnClose.php(28): App\Sock\Parser\OnClose->getInfoByFd()
#3 /home/www/im/EasySwooleEvent.php(75): App\Sock\Parser\OnClose->close()
#4 [internal function]: EasySwoole\EasySwooleEvent::EasySwoole\{closure}(Object(Swoole\WebSocket\Server), 1, -1)
#5 /home/www/im/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php(56): Swoole\Coroutine::call_user_func_array(Object(Closure), Array)
#6 /home/www/im/vendor/easyswoole/easyswoole/src/Core/Swoole/ServerManager.php(137): EasySwoole\Core\Component\Invoker::callUserFuncArray(Object(Closure), Array)
#7 [internal function]: EasySwoole\Core\Swoole\ServerManager->EasySwoole\Core\Swoole\{closure}(Object(Swoole\WebSocket\Server in /home/www/im/App/Service/RedisPoolService.php on line 23
访问域名也会包502 ...
请问这该如何进行了...