參考:https://gitee.com/Tinywan/dnmp
拉取代碼
git clone https://gitee.com/Tinywan/dnmp.git cd dnmp
新建配置文件
cp env.example .env
修改.env,對應共享目錄
SOURCE_SHARE_DIR=/mnt/hgfs/www
開啟容器服務
docker-compose up #docker-compose -f /mnt/hgfs/www/dnmp/docker-compose.yml up
守護進程 docker-compose up -d
nginx配置
配置文件端口必須和 docker-compose.yml的ports - 8088:80中的映射出來的端口一一對應
修改dnmp\conf\nginx.conf
#dnmp\conf\nginx.conf
upstream fastcgi_proxy{
server php74:9000;
}
#dnmp\conf\conf.d\hlyun\hlyun_gateway.conf
server {
listen 7003;
server_name localhost;
location / {
root /var/www/113frontend/dist;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ / redirect;
}
}
error_page 500 502 503 504 /50x.html;
location /api {
#rewrite ^.+api/?(.*)$ /$1 break;
#include uwsgi_params;
proxy_pass http://localhost:7002;
}
}
server {
listen 7002;
server_name localhost;
location / {
root /var/www/hlyun_v3/hlyun_gateway/src/public;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
root /var/www/hlyun_v3/hlyun_gateway/src/public;
fastcgi_pass fastcgi_proxy;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重新加載配置文件 docker exec -it dnmp-nginx nginx -s reload
修改php-fpm:
#dnmp\conf\php\php-fpm.d\www.conf pm = static pm.max_children = 30
進入PHP容器(該容器沒有bash shell。但在/bin/sh有一個shell):
docker exec -it dnmp-php74 /bin/sh
mysql5.7導入DATETIME字段數據時遇到錯誤incorrect datetime value '0000-0-0 00:00:00' for column
解決辦法:去掉NO_ZERO_IN_DATE,NO_ZERO_DATE
#dnmp\conf\mysql\my.cnf sql_mode ='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
