当前位置:网站首页>PHP laravel+gatewayworker completes im instant messaging and file transfer (Chapter 1: basic configuration)

PHP laravel+gatewayworker completes im instant messaging and file transfer (Chapter 1: basic configuration)

2022-06-26 12:21:00 Special sword

Effect display

 Insert picture description here

Function introduction

This topic will lead you to build Imitation A letter Of Instant messaging And complete the mutual transmission of documents

Application scenarios

Practical application scenarios of this topic :

  1. Chat customer service : Instant messaging , Messages are transmitted to each other in real time , Send text to each other 、 Voice messages and files ;
  2. Small scale online auction ;
  3. Video live barrage ;
  4. The Internet of things ;
  5. And other functions related to real-time messages ;

Special sections

  1. Server configuration
  2. Explanation of business logic
  3. Back end instant messaging code development and configuration item explanation
  4. Server debugging error
  5. Front and back end code development
  6. Function display

Chapter one : Configuration article

One 、 The tools needed

1. One server
2.laravel Basic mine construction
3. Basic development environment ( My server environment Linux+Nginx+PHP+Redis+Mysql) Be careful :wss Service requirements PHP edition >=5.6, Because wechat applet requires tls1.2, and PHP5.6 The following versions are not supported tls1.2, It doesn't matter if you don't understand , You use it directly >=php7 Just the version of
4. domain name ( Optional , If there is no domain name, we use the public network IP It can also be realized )
5. Domain name HTTPS certificate ( Optional )

Two 、 Configure server

1. Develop necessary ports , according to GatewayWorker manual
to open up
registerAddress Register service address port :1238
websocket Protocol port :8282
Redis Service port :6379

Be careful registerAddress Register service address port And websocket Protocol port this 2 Ports are customized , It doesn't have to be the same as my open port, just make sure that 2 Ports are not occupied , Also note : Port cannot be greater than 65535, Please make sure that the port is not occupied by other programs , Otherwise start will report an error . If the port is less than 1024, need root Permission to run GatewayWorker To have permission to listen , Otherwise, an error is reported and there is no permission

2. This is my port opening status
 Please add a picture description
3. For the convenience of demonstration, I choose the pagoda panel here , If you are also a pagoda panel user, please open your port again on this page according to your actual needs , Otherwise, the server security group will be opened , The pagoda panel does not open the corresponding port , The port is still unavailable ;
 Please add a picture description
4. Start downloading the necessary extensions

  • redis expand ( It's not necessary to pretend , It is mainly used to save temporary chat records )
  • Swoole4 expand
  • imagemagick(Imagick High performance graphics library )
  • fileinfo expand ( Without this extension, the front end of the address may not be able to upload files to php)
  • Be careful : I have installed the corresponding extensions , But the actual code development does not take effect , Pay attention to php Disable function problem of , Go to see if there are any dangerous functions that have been disabled, causing the functions to not work .

 Insert picture description here
 Insert picture description here
5. To configure Redis Extended password
 Insert picture description here

Next chapter :《2. Explanation of business logic

原网站

版权声明
本文为[Special sword]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170522215359.html