作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用Docker设置Symfony 3.x应用程序。
我通过docker-compose.yml文件配置了3个Docker容器:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- .:/var/www
- ./docker/vhost.conf:/etc/nginx/sites-enabled/vhost.conf
- ./docker/nginx.conf:/etc/nginx/nginx.conf
links:
- php
php:
image: php:5.6-fpm
volumes:
- .:/var/www
links:
- db
db:
image: mysql:latest
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=my-password
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen *:80;
server_name my-project.dev;
root /var/www/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
最佳答案
我必须通过创建如下图像来覆盖php-fpm图像的WORKDIR:
Dockerfile:
FROM php:5.6-fpm
MAINTAINER Firstname Lastname <firstname.lastname@domain.com>
WORKDIR /var/www
docker build -t companyx/php-5.6-fpm .
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- .:/var/www
- ./docker/vhost.conf:/etc/nginx/sites-enabled/vhost.conf
- ./docker/nginx.conf:/etc/nginx/nginx.conf
links:
- php
php:
image: companyx/php-5.6-fpm
volumes:
- .:/var/www
links:
- db
db:
image: mysql:latest
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=my-password
关于php - 找不到PHP文件,应根据配置的vHost找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40948024/
我是一名优秀的程序员,十分优秀!