CRMEB部署的一些修改
# CRMEB的swoole要开启ssl。但是前面安装的时候默认是不开启这项的。所以这里改成从源代码编译安装。
# 使用官方的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 mkdir -p /usr/src/swoole
COPY swoole-src/swoole-src-4.8.13 /usr/src/swoole
# 更新包列表并安装必要的软件包
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 \
openssl \
libssl-dev \
libcurl4-openssl-dev \
# && pecl install swoole-4.8.13 \
# && echo "extension=swoole.so" > /etc/php/7.4/mods-available/swoole.ini \
# && phpenmod swoole \
&& cd /usr/src/swoole \
&& phpize \
&& ./configure --enable-openssl --enable-sockets --enable-http2 --enable-swoole-json --enable-swoole-curl \
&& make -j$(nproc) \
&& make install \
&& 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/* /usr/src/swoole
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
# 暴露默认的PHP-FPM端口
EXPOSE 80
# 启动 Supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
在镜像编译的时候去clone代码会比较麻烦,这里就先把源码下载,用COPY指令复制到指定位置。
# CRMEB中ws问题
前面部署后的系统不能响应ws。经查,是主机中nginx配置的问题。现做些修改。
location / {
proxy_pass http://127.0.0.1:84;
# START
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# END
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;
}