tarsphp的安装使用

极客清韵
• 阅读 160

tarsphp的安装使用

1,安装tars核心组件

https://github.com/TarsCloud/...

详细按照官方文档基本上都能安装,出现错误的注意查看日志

2,安装web界面管理

cd /usr/local/tars
git clone https://github.com/TarsCloud/TarsWeb.git
cd /usr/local/tars/TarsWeb

替换配置文件

sed -i 's/db.tars.com/你的ip/g' config/webConf.js
sed -i 's/registry.tars.com/你的ip/g' config/tars.conf

安装

$ npm install --registry=https://registry.npm.taobao.org
$ npm run prd

具体报错可以查看日志cat /root/.npm/_logs/缺什么安装什么

打开3000端口看到界面

3,安装tarsphp以及官方例子,要求php5.6以上,需安装swoole扩展,redis扩展,phptars扩展

swoole和redis扩展安装这里不再赘述

phptars扩展安装

git clone https://github.com/TarsPHP/tars-extension.git
cd /opt/tars/TarsPHP/tars-extension
 /usr/local/php7.2.10/bin/phpize
./configure
./configure --with-php-config=/usr/local/php7.2.10/etc/php.ini
./configure --with-php-config=/usr/local/php7.2.10/bin/php-config
make install

修改php.ini配置支持扩展

查看扩展安装情况

/usr/local/php7.2.10/bin/php -m

下载tarsphp开发

git clone https://github.com/TarsPHP/Ta...

下载后可看到官方例子TarsActDemo

弹幕活动项目,其中包含3个服务。

涵盖了Http,Tcp服务,使用了Mysql,Redis存储,包含了用户登录、session校验、用户信息获取、弹幕创建、弹幕获取等功能。已经涵盖了平常业务开发的很多方面。

QD.ActHttpServer.obj是一个http服务,对外提供固定端口,这是业务服务,调用后端的User和Comment服务完成业务。

QD.ActCommentServer.CommentObj 是一个tcp服务,主要提供评论的写入和获取,存储在Redis中。

QD.UserService.UserObj 是一个tcp,主要提供用户信息获取,用户登录,用户Session校验。相关数据保存在Mysql中。

  • index.html是前端页面,连接http服务,实现弹幕展示。
  • act.tars.local.conf是nginx配置
  • user_info.sql是QD.UserServer服务的用户信息表

1).修改QD.UserService中src/ENVConf.php 中的mysql 配置,设置你们自己的mysql ip、port和db名字

2).导入user_info.sql到你的mysql中。

3).修改QD.ActCommentServer中src/ENVConf.php 中的redis 配置,设置你们自己的redis ip、port

4).依次cd 到各个服务的 src 目录,执行 composer install,安装composer 依赖

5).依次cd 到各个服务的 src 目录,执行 composer run-script deploy 打包代码

6).部署三个服务,QD.ActHttpServer是http服务,需要固定一个端口,选 非tars服务,发布模板需要新建

<tars>
 <application>
 enableset=${enableset}
 setdivision=${setdivision}
 <client>
 locator=${locator}
 sync-invoke-timeout=20000
 async-invoke-timeout=20000
 refresh-endpoint-interval=60000
 stat=tars.tarsstat.StatObj
 property=tars.tarsproperty.PropertyObj
 report-interval=60000
 modulename=${modulename}
 sample-rate=100000
 max-sample-count=50
 </client>
 <server>
 app=${app}
 server=${server}
 localip=${localip}
 local=${local}
 basepath=${basepath}
 datapath=${datapath}
 logpath=${logpath}
 loglevel=DEBUG
 logsize=15M
 log=tars.tarslog.LogObj
 config=tars.tarsconfig.ConfigObj
 notify=tars.tarsnotify.NotifyObj
 logLevel=DEBUG
 php=/usr/local/php7.2.10/bin/php
 buffer_output_size=12582912
 open_tcp_nodelay=1
 open_eof_check=0
 open_eof_split=0
 task_worker_num=1
 dispatch_mode=2
 daemonize=1
 protocolName=http
 </server>
 </application>
</tars>

其他两个是tcp 服务,端口随意,选 tars服务。

(注意部署的时候在平台上配置的ServantName要和我上面写的全称一样,如果你需要修改,请同步修改tars.proto.php,actComment.proto.php和userInfo.proto.php,并从新生成protocol中代码)

7).配置你的nginx,proxy_pass 修改为你的 QD.ActHttpServer服务的ip地址和端口

8).拷贝index.html 到你的/data/website/tarsact/中

9).打开看一下是否可以访问

10).输入一个用户名 yong密码123456执行以下登录

11).发个弹幕试试

12).刷新一下,你发的弹幕出来了吗?恭喜你 O(∩_∩)O哈哈~

tarsphp的安装使用

点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
芝士年糕 芝士年糕
3年前
修改MySQL密码的四种方法
整个3A的VPS搭建mysql真不错方法1:用setpassword命令 (1)首先要先登录MySQL:!image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/79be
Wesley13 Wesley13
4年前
java中比较两个时间的差值
项目背景1.某篇文稿的发布时间是publishDate,例如:2020072118:00:41。2.现要求判断该篇文稿的发布时间是否在近30天之内。publicstaticlongdayDiff(DatecurrentDate,DatepublishDate){LongcurrentTimecurrentDat
Easter79 Easter79
4年前
tarsphp的安装使用
!(https://six.club/image/show/attachments202009e5w4l59u5f6ff2c79a72d.png)1,安装tars核心组件https://github.com/TarsCloud/...(https://www.oschina.net/action/GoToLink?urlhtt
梦
4年前
微信小程序new Date()转换时间异常问题
微信小程序苹果手机页面上显示时间异常,安卓机正常问题image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/b691e1230e2f15efbd81fe11ef734d4f.png)错误代码vardate'2021030617:00:00'vardateT
Stella981 Stella981
4年前
KaliTools说明书+BurpSuit实战指南+SQL注入知识库+国外渗透报告
!(https://oscimg.oschina.net/oscnet/d1c876a571bb41a7942dd9752f68632e.gif"15254461546.gif")0X00KaliLinux Tools中文说明书!(https://oscimg.oschina.net/oscnet/
Wesley13 Wesley13
4年前
MySQL总结(十一)子查询
!(https://oscimg.oschina.net/oscnet/upa344f41e81d3568e3310b5da00c57ced8ea.png)子查询1\.什么是子查询需求:查询开发部中有哪些员工selectfromemp;通
Wesley13 Wesley13
4年前
Validation.FO, 简洁而不简单的验证框架。(来自41区)
下载地址1.参考:https://github.com/41zone/validation/(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fgithub.com%2F41zone%2Fvalidation%2F)2.(https://www.osc
皕杰报表的关系数据库数据源配置
1.首先在设计器里面!image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/b57243ea109235edcb344472099038a3.png)!image
新支点小玉 新支点小玉
2年前
CNAS资质认证,快速出证,欢迎咨询
!11284(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/4e90dd6f80dd2c80bdd3dc5e7d686a41.jpg)