Centos Linux 系统部署CRMEB PHP版应用系统5.3.0

前提条件

已安装 php 7.1~7.4 任意一个版本 已安装 nginx 已安装 redis 已安装 MYSQL数据库(推荐使用5.7版本)

部署过程

下载地址:https://down.chinaz.com/api/index/download?id=39155&type=code

接下来我们就按步骤来,进行部署操作

  1. 创建文件夹: 服务器端创建文件夹 crmeb,用于存放程序文件 我这里的全路径为 /opt/crmeb

  2. 上传程序文件: 将下载解压后的程序文件传到该目录

  3. 配置nginx: 在nginx配置中增加crmeb配置,内容如下

server {
   listen 80;
   server_name crmeb.test.com; # 替换为你的域名
   root /opt/crmeb/public/;
   index index.php index.html index.htm; 
   location / {
        root /opt/crmeb/public/;
        index index.php index.html index.htm;
       if (!-e $request_filename){
               rewrite  ^(.*)$  /index.php?s=$1  last;   break;
       }
   }

   location  ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;  
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
   }

   # 错误页面处理
   error_page 500 502 503 504 /50x.html;
}
  1. 重启nginx
service nginx restart
  1. 打开浏览器,输入刚才配置的域名 crmeb.test.com,会自动转入安装页面,在安装界面中勾选同意协议按钮,并点击 “下一步”按钮,进入下一个界面

  2. 在安装的第二步,界面会显示检测信息,分为“环境和配置检测”和“权限检测”,如果发现有红色的感叹号,表示存在问题,需要修复后,才能继续 这次安装中 “环境和配置检测”中,“bcmath”扩展存在问题 “权限检测”中 backup 目录 读写权限都不具备,其他目录没有写入权限

  3. 修复安装第二步的问题 修复“环境和配置检测”中的问题

	yum install -y php-bcmatch

修复“权限检测”问题,执行以下命令,问题全部修复后再执行下一步

	cd /opt/crmeb
	chmod -R 777 ./runtime/
	chmod -R 777 ./public/

8.此时进入第三个操作步骤,配置数据

填写 数据库密码

修改 管理员账号(可省略)

填写 管理员密码

填写 管理员密码(重复密码,用于确认一致)

选择 缓存设置, 我这里选择的是redis缓存

填写 redis服务器IP(默认为127.0.0.1)

填写 redis端口(默认为6379)

填写 redis数据库编号(默认为0)

填写 redis验证密码(没有的话,可以不填)

完成以下操作后,再执行下一步

问题1: 这时出现了一个提示信息 : 请在mysql配置文件修sql-mode或sql_mode为NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

需要配置数据库的sql_mode= NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

重启数据库

service mysqld restart

再回到操作界面,进行下一步操作

问题2: 提示信息:Redis扩展没有安装

我显示重启了一下redis服务,看看是否可以

service redis restart

再回到操作界面,进行下一步操作 ,还是不可以,为了省事,干脆改用文件缓存

再点击“下一步”

9.系统进入安装状态,“正在安装...”,等待安装过程完成。

10.安装完成后,系统会提示安装完成,并用大字体显示安装成功,下面还有两个按钮,一个是“进入前台”,一个是“进入后台”,到这就已经安装完成了。

用户体验

点击“进入前台”,进入商城界面

点击“进入后台”,进入后台登录界面,使用在第三个操作步骤,即本文第8点这个过程中设置的用户名和密码,登录进入后台。

消息队列

linux系统安装Supervisor管理器,添加守护进程

用户选择 www

运行目录选择项目根目录

启动命令:php think queue:listen --queue

定时任务

在自动收货,库存预警等功能使用到

php think timer [ status ] [ --d ]

参数

  • status: 状态
    • start: 启动
    • stop: 关闭
    • restart: 重启
  • --d : 后台执行

php think timer start --d

问题:

Workerman[think] start in DAEMON mode


                                                       
  [Error]                                              
  Call to undefined function Workerman\posix_getpid()  
                                                       


Exception trace:
 () at /opt/crmeb/vendor/workerman/workerman/Worker.php:2081
 Workerman\Worker::log() at /opt/crmeb/vendor/workerman/workerman/Worker.php:851
 Workerman\Worker::parseCommand() at /opt/crmeb/vendor/workerman/workerman/Worker.php:502
 Workerman\Worker::runAll() at /opt/crmeb/crmeb/command/Timer.php:67
 crmeb\command\Timer->execute() at /opt/crmeb/vendor/topthink/framework/src/think/console/Command.php:210
 think\console\Command->run() at /opt/crmeb/vendor/topthink/framework/src/think/Console.php:654
 think\Console->doRunCommand() at /opt/crmeb/vendor/topthink/framework/src/think/Console.php:313
 think\Console->doRun() at /opt/crmeb/vendor/topthink/framework/src/think/Console.php:250
 think\Console->run() at /opt/crmeb/think:19

需要安装 posix 扩展

yum install -y php-posix

实际上安装的是 php-process

重启一下php

service php-fpm restart

再次执行

php think timer start --d

Workerman[think] start in DAEMON mode
------------------------------------- WORKERMAN --------------------------------------
Workerman version:3.5.19          PHP version:7.2.24
-------------------------------------- WORKERS ---------------------------------------
proto   user            worker          listen          processes    status           
tcp     root            none            none            1             [OK]            
--------------------------------------------------------------------------------------
Input "php think stop" to stop. Start success.

成功开启了定时任务

长连接服务

在h5聊天,后台管理员消息通知等功能使用到

先修改网站nginx配置

location /notice {
    proxy_pass http://127.0.0.1:20002/;  
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-real-ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
}
location /msg {
    proxy_pass http://127.0.0.1:20003/;  
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-real-ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
}

对应的端口要和 /config/workerman.php 里面保持一致

linux系统直接运行

php think workerman [ status ] [ server ] [ --d ]

windows环境下需要分三步执行

# 内部通讯服务
php think workerman start channel
# h5端聊天服务
php think workerman start chat
# 后台管理员通知
php think workerman start admin

或者直接双击运行 /workerman.bat

参数

  • status: 状态

    • start: 启动
    • stop: 关闭
    • restart: 重启
  • server: 服务 (windows)

    • channel: 内部通讯
    • chat: h5
    • admin: 后台
  • --d : 后台执行

实际上linux 直接运行以下命令,即可全部启动

php think workerman start --d