初始化
parent
cbc4fe50d4
commit
147e1b9fc9
|
@ -46,4 +46,4 @@ AMQP_HOST=127.0.0.1
|
|||
AMQP_PORT=5672
|
||||
AMQP_USER=guest
|
||||
AMQP_PASSWORD=guest
|
||||
AMQP_VHOST=/
|
||||
AMQP_VHOST=/im
|
||||
|
|
119
README.md
119
README.md
|
@ -13,13 +13,11 @@ Lumen-IM 是一个网页版在线即时聊天项目,前端使用 Element-ui +
|
|||
- 支持编写个人笔记、支持笔记分享(好友或群)
|
||||
|
||||
## 2、项目Demo
|
||||
|
||||
- 地址: [http://im.gzydong.club](http://im.gzydong.club)
|
||||
- 账号: 18798272054 或 18798272055
|
||||
- 密码: admin123
|
||||
|
||||
## 3、环境要求
|
||||
|
||||
- PHP >= 7.2
|
||||
- Swoole >= 4.4
|
||||
- OpenSSL
|
||||
|
@ -28,5 +26,118 @@ Lumen-IM 是一个网页版在线即时聊天项目,前端使用 Element-ui +
|
|||
- Redis >= 5.0.0
|
||||
- AMQP
|
||||
|
||||
## 4、项目安装
|
||||
[接口文档](https://docs.apipost.cn/view/9c75130d7006e6e5#3184466)
|
||||
## 4、相关文档
|
||||
[Api 接口文档](https://docs.apipost.cn/view/9c75130d7006e6e5#3184466)
|
||||
[Hyperf 框架](https://hyperf.wiki/2.0/#/README)
|
||||
|
||||
## 5、项目安装
|
||||
1. 项目运行之前请确保 Mysql、Redis、RabbitMQ 及 Nginx 服务
|
||||
2. 拷贝项目根目录下 .env.example 文件为 .env 并正确配置相关参数(mysql、redis、rabbitmq)
|
||||
3. 执行数据库迁移文件命令生成相关数据表 `php bin/hyperf.php migrate`
|
||||
4. 启动运行项目 `php bin/hyperf.php start`
|
||||
|
||||
## Nginx 相关配置
|
||||
|
||||
##### 配置 Http 服务
|
||||
```
|
||||
upstream hyperfhttp {
|
||||
# Hyperf HTTP Server 的 IP 及 端口
|
||||
server 127.0.0.1:9503;
|
||||
}
|
||||
|
||||
server {
|
||||
# 监听端口
|
||||
listen 80;
|
||||
# 绑定的域名,填写您的域名
|
||||
server_name im-serve.xxx.com;
|
||||
|
||||
location / {
|
||||
client_max_body_size 20m;
|
||||
# 将客户端的 Host 和 IP 信息一并转发到对应节点
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# 转发Cookie,设置 SameSite
|
||||
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
|
||||
|
||||
# 执行代理访问真实服务器
|
||||
proxy_pass http://hyperfhttp;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 配置 WebSocket 服务
|
||||
```
|
||||
# 至少需要一个 Hyperf 节点,多个配置多行
|
||||
upstream hyperf_websocket {
|
||||
server 127.0.0.1:9504;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name im-socket.xxx.com;
|
||||
|
||||
location / {
|
||||
# WebSocket Header
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade websocket;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
|
||||
# 将客户端的 Host 和 IP 信息一并转发到对应节点
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
# 客户端与服务端无交互 60s 后自动断开连接,请根据实际业务场景设置
|
||||
proxy_read_timeout 60s ;
|
||||
|
||||
# 执行代理访问真实服务器
|
||||
proxy_pass http://hyperf_websocket;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 配置图片域名
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
server_name im-img.xxx.xxx;
|
||||
index index.html;
|
||||
|
||||
# 默认禁止访问
|
||||
location / {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# 只允许 访问 images 文件夹下的文件
|
||||
location ^~ /media/{
|
||||
# 设置目录别名(确保是项目上传文件目录)
|
||||
# 例如 upload_dir = /www/data/lumenim
|
||||
# 此时应配置 alias /www/data/lumenim/media/
|
||||
|
||||
alias /www/data/lumenim/media/;
|
||||
|
||||
# 设置缓存时间(3天)
|
||||
expires 3d;
|
||||
|
||||
# 关闭访问日志
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 注意事项
|
||||
1. 请确保 PHP 安装 openssl、redis、amqp 扩展
|
||||
2. 请确保 Swoole 扩展开启 openssl 扩展
|
||||
```
|
||||
[root@iZuf6cs69fbc86cwpu9iv3Z vhost]# php --ri swoole
|
||||
swoole
|
||||
Swoole => enabled
|
||||
Author => Swoole Team <team@swoole.com>
|
||||
Version => 4.5.9
|
||||
...
|
||||
openssl => OpenSSL 1.0.2k-fips 26 Jan 2017 (请确保此处开启)
|
||||
```
|
||||
|
||||
3. 请确保 RabbitMQ 中添加了对应的vhost
|
||||
|
|
|
@ -21,7 +21,7 @@ return [
|
|||
|
||||
'ip_address' => env('IP_ADDRESS', ''),
|
||||
|
||||
// 运行模式
|
||||
// 运行模式(预留)
|
||||
'run_mode' => 'cluster',
|
||||
|
||||
// 域名相关配置
|
||||
|
@ -36,7 +36,7 @@ return [
|
|||
'log_level' => [
|
||||
LogLevel::ALERT,
|
||||
LogLevel::CRITICAL,
|
||||
// LogLevel::DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
LogLevel::EMERGENCY,
|
||||
LogLevel::ERROR,
|
||||
LogLevel::INFO,
|
||||
|
|
Loading…
Reference in New Issue