我正在对我的symfony应用程序进行docker化,但是我无法弄清为什么会出现以下错误:
web_1 | 2018/09/11 07:21:40 [emerg] 1#1: invalid number of arguments in "try_files" directive in /etc/nginx/conf.d/default.conf:6
web_1 | nginx: [emerg] invalid number of arguments in "try_files" directive in /etc/nginx/conf.d/default.conf:6
这是我的配置:
server {
server_name localhost;
root /application/web;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/(index)\.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/project_error.log;
access_log /var/log/nginx/project_access.log;
}
到目前为止,这是我的docker-compose.yml:
version: "3"
services:
web:
image: nginx:latest
volumes:
- ./docker/nginx/default.template:/etc/nginx/conf.d/default.template
- ./:/application
ports:
- "8080:80"
links:
- php
environment:
- NGINX_HOST=localhost
- NGINX_PORT=80
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
php:
image: php:7.2-fpm
当前,我只是在尝试使NGINX运行而不会导致配置错误。我不希望symfony应用程序本身可以工作。只是NGINX与PHP-fpm结合在一起。