CRMEB PHP多商户版DOCKER部署实战

#首先,制作docker 镜像#

官方有一个镜像,但是拉不来下,也不知道是没是没有维护,嘎了。只能自己动手做一个。

这里选择ubuntu 24 为基础,制作crmeb-mer的镜像,Dockerfile内容如下:

# 使用官方的Ubuntu 24.04镜像作为基础镜像
FROM ubuntu:24.04

# 设置环境变量以避免交互式配置工具
ENV DEBIAN_FRONTEND=noninteractive

# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone

# 更新包列表并安装必要的软件包
RUN apt-get update && \
    apt-get install -y software-properties-common ca-certificates nginx supervisor && \
    add-apt-repository ppa:ondrej/php && \
    apt-get update && \
    apt-get install -y \
        php7.4 \
        php7.4-cli \
        php7.4-fpm \
        php7.4-dev \
        php7.4-bcmath \
        php7.4-soap \
        php7.4-intl \
        php7.4-readline \
        php7.4-ldap \
        php7.4-msgpack \        
        php7.4-igbinary \
        php7.4-mysql \
        php7.4-pgsql \
        php7.4-gd \
        php7.4-imagick \
        php7.4-curl \
        php7.4-mbstring \
        php7.4-xml \
        php7.4-zip \
        php7.4-redis \
        php7.4-memcached \
        php7.4-amqp \
        git \
        unzip \
        curl \
    && pecl install swoole-4.8.13 \
    && echo "extension=swoole.so" > /etc/php/7.4/mods-available/swoole.ini \
    && phpenmod swoole \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY swoole_loader74.so /usr/lib/php/20190902
RUN echo "extension=swoole_loader74.so" > /etc/php/7.4/mods-available/swoole_loader.ini \
    && phpenmod swoole_loader 

# 确保目录存在
RUN mkdir -p /run/php \
    && chown -R www-data:www-data /run/php

# 设置工作目录
WORKDIR /var/www/html

# 设置权限
RUN chown -R www-data:www-data /var/www/html

# 配置 Nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY default /etc/nginx/sites-available/default

# 配置 Supervisor
COPY supervisord.conf /etc/supervisord.conf
COPY crmeb_swoole.conf /etc/supervisor/conf.d
COPY crmeb_queue.conf /etc/supervisor/conf.d

# 暴露默认的PHP-FPM端口
EXPOSE 80

# 启动 Supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

执行编译命令:

docker build -t my-crmeb:7.4 .

#下面来配置nginx#

nginx 配置文件nginx.conf如下:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

主要是打开了gzip设置。里面没用的注释直接删了吧。

配置默认站点, 文件default内容如下 :

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
        listen 80;
        listen [::]:80;

        root /var/www/html/public;

        # Add index.php to the list if you are using PHP
        index index.php;

        server_name localhost;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";

        #location / {
        #        # First attempt to serve request as file, then
        #        # as directory, then fall back to displaying a 404.
        #        try_files $uri $uri/ /index.php?$query_string;
        #}

#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:8324;
    proxy_http_version 1.1;
    proxy_read_timeout 360s;   
    proxy_redirect off; 
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

    add_header X-Cache $upstream_cache_status;

    #Set Nginx Cache


    set $static_fileLzXnun8E 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
     set $static_fileLzXnun8E 1;
     expires 12h;
        }
    if ( $static_fileLzXnun8E = 0 )
    {
    add_header Cache-Control no-cache;
    }
}

#PROXY-END/

        charset utf-8;

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;

        # pass PHP scripts to FastCGI server
        #

        #location ~ \.php$ {
        #    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        #    fastcgi_index index.php;
        #    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #    include fastcgi_params;
        #    fastcgi_hide_header X-Powered-By;
        #}

        #location ~ /\.(?!well-known).* {
        #    deny all;
        #}

        access_log /var/log/nginx/app_access.log;
        error_log /var/log/nginx/app_error.log;

}

这里注意location ~ \.php$ 的设置,普通的php-fpm配置在这里是不需要的,所有的PHP程序都通过swoole来解析。

#接着是supervisord服务#

supervisord.conf 内容如下:

[supervisord]
nodaemon=true
logfile=/var/log/nginx/supervisord.log
pidfile=/run/supervisord.pid

#[program:php-fpm]
#command=/usr/sbin/php-fpm7.4 --nodaemonize --fpm-config /etc/php/7.4/fpm/php-#fpm.conf
#autostart=true
#autorestart=true
#stdout_logfile=/var/log/nginx/php-fpm.stdout.log
#stderr_logfile=/var/log/nginx/php-fpm.stderr.log

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/var/log/nginx/nginx.stdout.log
stderr_logfile=/var/log/nginx/nginx.stderr.log

[include]
files = /etc/supervisor/conf.d/*.conf

这里php-fpm服务被禁用了。因为用不着,所有代码都通过swoole解析。

crmeb需要建两个守护进程,按道理可以跟nginx一样,放到supervisord.conf文件,这里只是为了测试docker里supervisord能不能加载配置文件,所以多加了两个文件。

crmeb系统的启动,crmeb_swoole.conf配置如下:

[program:crmeb-swoole]
command=/usr/bin/php7.4 /var/www/html/think swoole restart
autostart=true
autorestart=true
stdout_logfile=/var/log/nginx/crmeb-swoole.stdout.log
stderr_logfile=/var/log/nginx/crmeb-swoole.stderr.log

crmeb的队列启动,crmeb_queue.conf配置如下:

[program:crmeb-queue]
command=/usr/bin/php7.4 /var/www/html/think queue:listen --tries=2
autostart=true
autorestart=true
stdout_logfile=/var/log/nginx/crmeb-queue.stdout.log
stderr_logfile=/var/log/nginx/crmeb-queue.stderr.log

这两个配置都放supervisord.conf文件里好了,反正supervisorctl也用不了。

#swoole#

制作镜像时还用到swoole_loader74.so文件,这个文件在crmeb程序的安装包里,位置:

crmeb_mer/install/swoole-loader/

找到对应自己PHP版本的swool-loader.so文件放到Dockerfile同级目录下。

#部署#

执行如下命令:

docker run -itd --name=crmeb-mer \

            -v /data/etc/b2b/crmeb_supervisord:/etc/supervisor/conf.d \

            -v /var/www/b2b/crmeb_mer:/var/www/html \

            -v /data/log/crmeb:/var/log/nginx \

            -p 83:80 \

            my-crmeb:7.4

这里多挂载了一个/etc/supervisor/conf.d目录,因为前面说的,为了测试supervisord是否能加载多个配置文件。

所有的日志全部都重定向到了/var/log/nginx目录。

按上述操作,应该会得到一个正常运行的crmeb容器。

为了能让外网能访问,还需要在主机上做个反向代理。

这里只是让crmeb程序在docker里跑,mysql,redis还是在主机上安装配置的,并且主机上还安装了一套nginx,用来反向代理多个容器中的系统。

crmeb的nginx反向代理配置如下:

server {
    listen       80;
    server_name  mer.mysite.com;


    charset utf-8;

    #access_log  /var/log/nginx/host.access.log  main;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location / {
        proxy_pass   http://127.0.0.1:83;
        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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.(?!well-know).* {
        deny  all;
    }


}

域名绑定之后,外网即可正常访问crmeb系统。

-完-

CRMEB单商户商城打通基于Thinkphp6.0+vue+mysql+redis开发,前后台全部采用前后端分离式开发。前端框架为uni-app,多端合一,首页页面后台可视化编辑操作,后台采用iview框架。 系统功能强大,打通H5端与小程序端数据,PC后台管理,纯源码建站,数据私有,随心掌控。各类营销功能齐全,拼团功能让订单倍增;邀请多人砍价让商城人气爆棚,快速提升商城知名度;限时秒杀促成交转化,提高商城营业额;会员等级管理,积分管理留存新用户/激活老用户,多门店功能实现O2O商业新模式以及优惠卷/分销等众多实用强大功能,一站式解决你运营难,功能少的烦恼。 CRMEB单商户商城系统功能列表: 1. 分销拓客功能 利用微信社交好友分销推广,设置佣金可以快速的发展积累商城的忠实粉丝。 2. 拼团功能 拼团功能已经是一个商城系统的标配功能,可以邀请好友拼团是的商城订单成倍提升,增加收益。 3. 砍价功能 可以快速邀请微信好友砍价,增加商城曝光,获取意向客户。 4. 秒杀 当你有爆款产品想要快速推出,这将是一个绝对的营销利器,可以快速提高成交率。 5. 优惠券功能 可以帮助企业激活沉睡客户,有效刺激消费。 6. 在线支付功能 其商城对接了微信支付,并设有余额支付功能,客户可自行选择支付方式,可以充值到系统进行支付。 7. 用户画像功能 可以快速了解用户的消费行为,消费偏好,消费能力,将客户细分归类。 8. 精准营销功能 进行大数据分析,对目标客户精准营销,有的放矢。 9. 反馈评价功能 用户可以对产品服务进行评价,对意向客户将产生购买引导。 10. 物流追踪功能 发货商品用户可以实时查询订单物流状态。 11. 云存储功能 后台集成七牛云,阿里云oss,腾讯COS 12. 短信通知功能 微信订单消息不仅可以通过微信提醒,还可以通过短信提醒,及时跟踪用户下单情况。 13. 到店核销功能 后台系统可以设置多门店,可以利用到店核销功能进行线上促销引流,线下核销提货,快速引流到店率翻倍。 14. 手机订单管理功能 可以实时掌握商城数据,随时随地管理生意。 15. 小票打印功能 用户下单自动打印订单小票,快速处理用户订单。 演示账号:demo    密码:crmeb.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HOOLOO

技术分享,回馈社会,建设祖国。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值