docker-compos安裝php專案-可道雲kodbox

明月心~發表於2024-11-22

docker-compos安裝php專案-可道雲kodbox

從倉庫下載

git clone https://github.com/kalcaddle/kodbox.git
git clone https://gitee.com/thinkyoung/kodbox.git

複製待對應目錄

將內容複製到./data/kodbox/html目錄

修改配置檔案docker-compose.yml

services:
  php-kodbox:
    image: php:7.4-apache
    #image: php_app:latest
    container_name: php-kodbox
    environment:
      # APACHE_DOCUMENT_ROOT=/var/www/html/public
      # APACHE_STATIC_PORT_80: 8086 # 沒有用
      # 時區上海
      TZ: Asia/Shanghai
    ports:
      - "8086:80"
    volumes:
      - ./data/kodbox/html:/var/www/html
      # - ./data/kodbox/conf/ports.conf:/etc/apache2/ports.conf
      # - ./data/kodbox/log:/var/log/apache2
      #- ./data/kodbox/certs:/etc/apache2/ssl
    # privileged: true
    restart: no
    networks:
      my_net:
        ipv4_address: 172.30.0.162
    deploy:
      resources:
        limits:
          #cpus: 0.25
          memory: 512M
        reservations:
          #cpus: 0.2
          memory: 256M
networks:
  my_net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.30.0.0/16

可以修改php啟動埠

容器內的配置檔案/etc/apache2/ports.conf

nginx代理返回靜態檔案中路徑不帶埠的問題

修改配置檔案/etc/nginx/nginx.conf
proxy_set_header Host $host;改為proxy_set_header Host $host:$server_port;

    server {
        listen       8086;
        server_name  localhost;
        #gzip off;

        location / {
            proxy_set_header Host $host:$server_port;    # 這裡加上$host:$server_port
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://10.***.***.46:8086/;
            proxy_set_header  X-Forwarded-Proto  $scheme;
            #sub_filter 'src="/' 'src="http://111.***.***.61:8086/';
            #sub_filter_once off;
        }
    }

相關文章