您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
docker-composer脚本編寫系列之nginx與php的結合
发布时间:2022-02-20 17:53:16编辑:雪饮阅读()
docker-compose.yml實例如:
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./html:/etc/nginx/html:rw
php:
image: php:fpm
ports:
- "9001:9000"
volumes:
- ./html:/etc/nginx/html:rw
該文件中對應上面web容器中nginx鏡像配置,這裏有兩個地方需要注意,第一個就是
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
autoindex on;
index index.html index.htm;
}
location ~ \.php$ {
root html;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
fastcgi_index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
還有就是解析php段裏面最好設置一個root即根目錄
root html;
关键字词:docker-composer,php,nginx
相关文章
- webman-配置數據庫-pdo_pgsql擴展安裝(php7.3.4)
- webman-配置數據庫-psql基本使用及php7.3.4中pgsql擴
- 基于GuzzleHttp(thinkphp5实现原生获取獲取微信公衆平
- workerman16进制与2进制字符串的转换(局限有点狭隘,應該
- workerman系列之nginx配置反向代理于workerman時候實
- workerman系列之tp5(thinkphp5)日志结合workerman使用
- workerman常见问题-php的几种回调写法-类的静态方法作
- workerman常见问题-php的几种回调写法-类方法作为回调
- workerman常见问题-php的几种回调写法-普通函数回调
- workerman創建https服務(普通請求轉https請求,基於寶塔