app開發公(gōng)司

mac 環境docker運行crmeb pro2.0


1 為(wèi)什麽mac上要用(yòng)docker運行?

直接運行項目不是更方便高效嗎?

是的,但crmeb pro 2.0使用(yòng)swoole和swoole 加密技(jì )術,需要swoole+swoole loader配合使用(yòng)才行,但目前crmeb pro 2.0官方還未支持mac版本的swoole loader;隻能(néng)選擇docker運行

Untitled
Untitled

2 docker 運行環境 搭建注意

使用(yòng)dnmp作(zuò)為(wèi)基礎:

https://github.com/yeszao/dnmp

提前說明注意事項:

1 swoole不能(néng)為(wèi)框架内的4.5.2,升級為(wèi)4.6.7,可(kě)以正常運行

https://github.com/swoole/swoole-src/releases/tag/v4.6.7 下載 Source code (tar.gz) 壓縮包 下載完成重名(míng)為(wèi) swoole-4.6.7.tgz
放到 dnmp/services/php/extensions 目錄下

dnmp/services/php/extensions/install.sh 607行 修改為(wèi)

installExtensionFromTgz swoole-4.6.7 

https://github.com/yeszao/dnmp/issues/376#issuecomment-865412930

2 swoole loader需要手動添加到php.ini

extension=/www/help/swoole_loader/swoole_loader73.so

3 docker-compose中(zhōng)添加啓動命令:

extra_hosts:
      - "www.site1.com:172.17.0.1"     command:
      - /bin/sh
      - -c
      - |
        cd /www/
        rm -f runtime/swoole.pid
        php think swoole
        php think queue:listen --tries=2     volumes:
      - ${SOURCE_DIR}:/www/:rw
dockfile
dockfile

4 項目文(wén)件public/.user.ini删除跨域限制代碼

docker-compose
docker-compose

5 php使用(yòng)7.3,為(wèi)了和線(xiàn)上保持一緻

.env
PHP_VERSION=7.3.29 PHP_PHP_CONF_FILE=./services/php/php.ini
PHP_FPM_CONF_FILE=./services/php/php-fpm.conf
PHP_LOG_DIR=./logs/php
PHP_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,swoole,redis,bcmath,sdebug,zip

3 完整代碼

修改的劃線(xiàn)

.env

# PHP source directory
#
SOURCE_DIR=../server

........
PHP_VERSION=7.3.29 PHP_PHP_CONF_FILE=./services/php/php.ini
PHP_FPM_CONF_FILE=./services/php/php-fpm.conf
PHP_LOG_DIR=./logs/php
PHP_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,swoole,redis,bcmath,sdebug,zip
........

docker-compose.yml

version: "3" services:
  nginx:
    build:
      context: ./services/nginx
      args:
        NGINX_VERSION: nginx:${NGINX_VERSION}
        CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
        NGINX_INSTALL_APPS: ${NGINX_INSTALL_APPS}
    container_name: nginx
    ports:
      - "${NGINX_HTTP_HOST_PORT}:80"       - "${NGINX_HTTPS_HOST_PORT}:443"     volumes:
      - ${SOURCE_DIR}:/www/:rw
      - ${NGINX_SSL_CERTIFICATE_DIR}:/ssl:rw
      - ${NGINX_CONFD_DIR}:/etc/nginx/conf.d/:rw
      - ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf:ro
      - ${NGINX_FASTCGI_PHP_CONF}:/etc/nginx/fastcgi-php.conf:ro
      - ${NGINX_FASTCGI_PARAMS}:/etc/nginx/fastcgi_params:ro
      - ${NGINX_LOG_DIR}:/var/log/nginx/:rw
    environment:
      TZ: "$TZ"     restart: always
    networks:
      - default   php:
    build:
      context: ./services/php
      args:
        PHP_VERSION: php:${PHP_VERSION}-fpm-alpine
        CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
        PHP_EXTENSIONS: ${PHP_EXTENSIONS}
        TZ"$TZ"     container_name: php
    expose:
      - 9501     extra_hosts:
      - "www.site1.com:172.17.0.1"     command:
      - /bin/sh
      - -c
      - |
        cd /www/
        rm -f runtime/swoole.pid
        php think swoole
        php think queue:listen --tries=2     volumes:
      - ${SOURCE_DIR}:/www/:rw
      - ${PHP_PHP_CONF_FILE}:/usr/local/etc/php/php.ini:ro
      - ${PHP_FPM_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf:rw
      - ${PHP_LOG_DIR}:/var/log/php
      - ${DATA_DIR}/composer:/tmp/composer
    restart: always
    cap_add:
      - SYS_PTRACE
    networks:
      - default ........

services/php/php.ini

;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
extension=/www/help/swoole_loader/swoole_loader73.so
;;;;;;;;;;;;;;;;;;;
; Module Settings ;

servicesphp/extension/install.sh

if [[ -z "${EXTENSIONS##*,swoole,*}" ]]; then
    echo "---------- Install swoole ----------"     isPhpVersionGreaterOrEqual 7 0     if [[ "$?" = "1" ]]; then
        installExtensionFromTgz swoole-4.6.7     else         installExtensionFromTgz swoole-2.0.11     fi
fi

services/nginx/conf.d/localhost.conf

server {
    listen       80  default;
    server_name  localhost;
    root   /www/public;
    index  index.php index.html index.htm;
    #charset koi8-r;
    
    access_log /dev/null;
    #access_log  /var/log/nginx/nginx.localhost.access.log  main;
    error_log  /var/log/nginx/nginx.localhost.error.log  warn;
    
    #error_page  404              /404.html;

    # 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 ~ [^/]\.php(/|$) {
        fastcgi_pass   php:9000;
        include        fastcgi-php.conf;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
    #PROXY-START/     location  ~* \.(php|jsp|cgi|asp|aspx)$
    {
        proxy_pass http://php:20199;         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;
    }
    location /
    {
        if (!-e $request_filename) {
             proxy_pass http://php:20199;         }
        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

           add_header Cache-Control no-cache;
        expires 12h;
    }
    #PROXY-END/
}

本地運行:(mysql/redis使用(yòng)線(xiàn)上環境)

cd docker

docker-compose up

那些快被玩爛的app推廣方式:再不用(yòng)就沒機會了!
如何找一家靠譜的APP開發公(gōng)司?

關聯文(wén)章

留言

您的信息會被保密處理(lǐ). 必填字段 *

現在就與BNA技(jì )術專家交流

400-021-7895

App開發 · 小(xiǎo)程序開發 · 網站 · 電(diàn)商(shāng) · 微信 · 系統定制 · 網絡營銷

技(jì )術強團,源碼輸出,高端定制,0預付開工(gōng)
潛心緻力于技(jì )術開發,為(wèi)用(yòng)戶提供卓越的互聯網工(gōng)具(jù)
一手源碼工(gōng)廠-合同保障-免費技(jì )術服務(wù)

0.065265s