【问题标题】:Laravel Valet 504 Gateway Time-out nginx/1.19.6 after 60 secondsLaravel Valet 504 Gateway Time-out nginx/1.19.6 after 60 seconds
【发布时间】:2021-08-10 22:12:18
【问题描述】:

我按照这里的所有说明进行操作:

https://github.com/laravel/valet/issues/315

我注意到性能更好,尤其是在更新 Valet 的 PM 池配置之后。 (现在一些执行开始完成,因为所需的时间不到 60 秒)。

但如果执行时间较长,60 秒后仍会显示错误。

其实我的conf。文件是这样的:

代客-fpm.conf

; FPM pool configuration for Valet

[valet]
user = xxx
group = staff
listen = /Users/xxx/.config/valet/valet.sock
listen.owner = xxx
listen.group = staff
listen.mode = 0777

;; When uncommented, the following values will take precedence over settings declared elsewhere
;php_admin_value[memory_limit] = 512M
;php_admin_value[upload_max_filesize] = 128M
;php_admin_value[post_max_size] = 128M

;php_admin_value[error_log] = /Users/xxx/.config/valet/Log/php-fpm.log
;php_admin_flag[log_errors] = on


;; Note: increasing these values will increase the demand on your CPU and RAM resources
pm = dynamic
;pm.max_children = 5
;pm.start_servers = 2
;pm.min_spare_servers = 1
;pm.max_spare_servers = 3

pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.process_idle_timeout = 10s
pm.max_requests = 500

valet.conf

server {
    listen 127.0.0.1:80 default_server;
    root /;
    charset utf-8;
    client_max_body_size 128M;

    location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
        internal;
        alias /;
        try_files $uri $uri/;
    }

    location / {
        rewrite ^ "/Users/xxx/.composer/vendor/laravel/valet/server.php" last;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log "/Users/xxx/.config/valet/Log/nginx-error.log";

    error_page 404 "/Users/xxx/.composer/vendor/laravel/valet/server.php";

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass "unix:/Users/xxx/.config/valet/valet.sock";
        fastcgi_index "/Users/xxx/.composer/vendor/laravel/valet/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "/Users/xxx/.composer/vendor/laravel/valet/server.php";
        fastcgi_param PATH_INFO $fastcgi_path_info;

        proxy_connect_timeout       3000;
        proxy_send_timeout          3000;
        proxy_read_timeout          3000;
        send_timeout                3000;
    }

    location ~ /\.ht {
        deny all;
    }
}

nginx.conf

user "xxx" staff;
#worker_processes auto;
worker_processes 8;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type  application/octet-stream;

    sendfile on;
    keepalive_timeout  650;
    types_hash_max_size 2048;

    client_max_body_size 1024M;


    client_header_timeout 3000;
    client_body_timeout 3000;
    fastcgi_read_timeout 3000;
    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;



    server_names_hash_bucket_size 128;

    ssi on;

    gzip  on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;

    include "/Users/xxx/.config/valet/Nginx/*";
    include servers/*;
    include valet/valet.conf;
}

我还应该修改什么? 提前致谢

【问题讨论】:

    标签: laravel nginx fpm http-status-code-504 laravel-valet


    【解决方案1】:

    在您的 Nginx 配置中,确保将其添加到 location ~ \.php$ 块下

    location ~ \.php$ {
        #...
        #fixes timeouts
        fastcgi_read_timeout 777;
    }
    

    【讨论】:

    • 我会给它一个机会!感谢您的回答!
    • 不客气,我在 Linux 上遇到了 Valet-plus 的类似问题,这对我有用
    • 为什么是 777?
    • 只需添加至少 600 及以上的任何数字,这意味着读取超时将至少为 600 秒或 10 分钟
    猜你喜欢
    • 1970-01-01
    • 2012-10-09
    • 2019-07-10
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 2019-06-24
    • 1970-01-01
    • 2011-09-28
    相关资源
    最近更新 更多