使用此项目/Docker 设置: https://gitlab.com/martinpham/symfony-5-docker
当我这样做时,docker-compose up -d我必须等待大约 2-3 分钟才能真正让它工作。在加载之前,它会给我“502 Bad Gateway”并记录错误:
2020/05/10 09:22:23 [error] 8#8: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.28.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://172.28.0.3:9000", host: "localhost"
为什么 nginx 或 php-fpm 或 smth else 加载这么慢?这是我第一次使用 nginx 和 Symfony。这是正常的吗?我希望它最多在 1-2 秒内加载,而不是 2-3 分钟。
是的,我见过类似的问题,但没有适合我的解决方案。应该更改一些 nginx/php-fpm/docker-compose 配置——我试过了,但没有成功。我修改了一点nginx/sites/default.conf(只是添加了 xdebug 的东西)
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name localhost;
root /var/www/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 4 256k;
fastcgi_buffer_size 128k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#!!!!fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
fastcgi_param PHP_VALUE "xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_host=192.168.0.12";
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}
nginx/conf.d/default.conf:
upstream php-upstream {
server php-fpm:9000;
}
慕斯王