宝塔面板部署HasChat

接上一个手动部署HasChat的帖子,群友要求出一个宝塔版的安装帖,那我就写一个吧~~

一、环境

1、CentOS7.9
2、Windows10(win7及以上均可)
3、宝塔面板
4、HBuilderX

二、步骤

1、安装Nginx1.22.0和Mysql8

点击软件商店–>运行环境,找到Nginx点击安装,版本选择1.22
点击软件商店–>运行环境,找到Mysql点击安装,版本选择8.0

安装基础环境1

2、安装PM管理器

点击软件商店–>搜索PM,找到PM点击安装,版本选择5.5

安装基础环境2

3、编译haschat

打开vscode,将haschat导入进去

编译haschat1
编译haschat2

配置.env.production

编译haschat2

开始编译haschat

编译haschat3

4、编译haschatapp

打开HBuilderX导入项目开始编译打包

先对haschatapp进行模块安装

1
npm install

然后开始打包
编译打包1
编译打包1
编译打包1
编译打包1
编译打包1
编译打包1
编译打包1

5、创建一个站点

点击网站–>添加站点

添加站点1

将刚才打包好的haschat和haschatapp上传到目录中并重命名

haschat
haschatapp
haschatapp
haschatapp

6、创建数据库并导入sql脚本

点击数据库–>添加数据库

mysql1

点击数据库–>导入,然后选择service中store文件夹下的几个sql文件

mysql2

7、上传后端文件到目录里并配置数据库

上传文件

uf

配置数据库

cond1
cond2
cond3
cond4

8、启动后端

pm1
pm1
pm1

9、配置Nginx

ninx1

ctrl+a权限,然后把下面这段复制粘贴进去

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
worker_processes auto;
worker_rlimit_nofile 51200;
events
{
worker_connections 51200;
multi_accept on;
}
stream {
upstream socket_server{
server 127.0.0.1:9527 weight=1;
}


server {
listen 3100;
proxy_pass socket_server;
}
}
http {
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;

server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;

server_tokens off;
access_log off;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}
location /nginx_status {
allow 127.0.0.1;
deny all;
stub_status on;
access_log off;
}
}
include vhost/*.conf;
}

ninx2

ctrl+a权限,然后把下面这段复制粘贴进去

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
server {
listen 80;
charset utf-8;
server_name 172.16.227.31;
client_max_body_size 300m;
access_log C:/BtSoft/wwwlogs/172.16.227.31.log;
error_log C:/BtSoft/wwwlogs/172.16.227.31.error.log;
gzip on;
gzip_comp_level 9;
gzip_types text/css text/plan text/xml application/javascript application/x-javascript application/html application/xml image/png image/jpg image/jpeg image/gif image/webp image/svg+xml;


location /haschat/{
alias C:/wwwroot/172.16.227.31/haschat/;
try_files $uri $uri/ /haschat/index.html;
index index.html index.htm;

}

location /haschatapp/ {
alias C:/wwwroot/172.16.227.31/haschatapp/;
try_files $uri $uri/ /haschatapp/index.html;
index index.html index.htm;
}

location /gif/{
root C:/wwwroot/172.16.227.31/haschat/;
}

location /emo/{
root C:/wwwroot/172.16.227.31/haschat/;
}




location /api/{
charset utf-8;
proxy_pass http://127.0.0.1:9527;
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
}


location ^~ /socket.io/ {
proxy_pass http://127.0.0.1:9527;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

}
}

ninx3

10、重启下Nginx就可以啦

ninx3

9、最后我们就部署完毕了,看下效果图
效果1
效果2
效果3
效果4

觉得不错的话,就用微信扫一扫二维码关注我吧~~

戴戴的Linux

文章目录
  1. 1. 接上一个手动部署HasChat的帖子,群友要求出一个宝塔版的安装帖,那我就写一个吧~~
  • 一、环境
  • 二、步骤
    1. 1. 觉得不错的话,就用微信扫一扫二维码关注我吧~~


  • 本站总访问量 本文总阅读量