原文链接:https://www.chenweiliang.com/cwl-30321.html
当我们在 CWP7.pro 服务器上的WordPress时,使用WordPress插件ChatGPT AI Power: Complete AI Pack时,出现以下错误提示消息“It appears that your web server has some kind of timeout limit.
”,这意味着CWP 网关没有收到来自上游服务器或应用程序的及时响应。
CWP7如何设置延长timeout limit?
CWP7免费版只需修改以下2个设置即可:
- 修改代理设置的超时值
- 更改default_socket_timeout
1、修改代理设置的超时值
编辑 /etc/nginx/proxy.inc
文件,将以下timeout值修改为600 ▼
proxy_connect_timeout 600s;
proxy_send_timeout 600;
proxy_read_timeout 600;
2、更改default_socket_timeout
在CWP控制面板左侧点击 → PHP Settings → PHP.ini Configuration ▼
在CWP控制面板左侧点击 → PHP Settings → PHP.ini Configuration "/>
或者编辑 /usr/local/php/php.ini
文件,搜索”default_socket_timeout
“,修改为600 ▼
default_socket_timeout 600
CWP7 Pro专业付费版,还需再修改配置文件
如果使用CWP7 Pro专业付费版的,可能还需要更改 PHP-FPM 配置:
1、默认位置:
/opt/alt/php-fpm72/usr/etc/
/opt/alt/php-fpm72/usr/etc/php-fpm.d/
/opt/alt/php-fpm72/usr/etc/php-fpm.d/users/
2、添加以下值cwpsvc.conf文件:
# vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/cwpsvc.conf
[cwpsvc]listen = /opt/alt/php-fpm72/usr/var/sockets/cwpsvc.sock
listen.owner = cwpsvc
listen.group = cwpsvc
listen.mode = 0640
user = cwpsvc
group = cwpsvc
;request_slowlog_timeout = 5s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-cwpsvc.log
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 1000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
3、添加以下值nobody.conf 文件:
# vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/users/nobody.conf
[nobody]listen = /opt/alt/php-fpm72/usr/var/sockets/nobody.sock
listen.allowed_clients = 127.0.0.1
listen.owner = nobody
listen.group = nobody
listen.mode = 0660
user = nobody
group = nobody
;request_slowlog_timeout = 15s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-nobody.log
pm = ondemand
pm.max_children = 1000
pm.max_requests = 6000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
env[PATH] = /usr/local/bin:/usr/bin:/bin
4、更改以下内容:
# vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/users/datahead.conf
[datahead]listen = /opt/alt/php-fpm72/usr/var/sockets/datahead.sock
listen.allowed_clients = 127.0.0.1
;listen.owner = "datahead"
listen.group = "nobody"
listen.mode = 0660
user = "datahead"
group = "datahead"
;request_slowlog_timeout = 15s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-datahead.log
pm = ondemand
pm.max_children = 1000
pm.max_requests = 4000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /home/datahead/tmp
env[TMPDIR] = /home/datahead/tmp
env[TEMP] = /home/datahead/tmp
env[PATH] = /usr/local/bin:/usr/bin:/bin
- 注意:仅更改仅标记为蓝色的值。
现在让我们在 Nginx 虚拟主机配置中,添加fastcgi_read_timeout变量。
如果你使用 PHP-FPM 托管然后添加(你可以使用 600s):
# vi /etc/nginx/conf.d/vhosts/datahead.biz.ssl.conf
fastcgi_pass unix:/opt/alt/php-fpm72/usr/var/sockets/datahead.sock;
fastcgi_index index.php;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include /etc/nginx/fastcgi_params;
如果你使用 PHP-CGI ,那么使用它的nginx.conf文件:
# Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
proxy_buffers 32 4k;
如果你使用 PHP 选择器 2:
# sed -i 's,^upload_max_filesize =.*$,upload_max_filesize = 4096M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^post_max_size =.*$,post_max_size = 4146M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^memory_limit =.*$,memory_limit = 5120M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_input_time =.*$,max_input_time = 300,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_execution_time =.*$,max_execution_time = 300,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^; max_input_vars =.*$,max_input_vars = 5000,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_file_uploads =.*$,max_file_uploads = 50,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^allow_url_fopen =.*$,allow_url_fopen = On,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^allow_url_include =.*$,allow_url_include = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^short_open_tag =.*$,short_open_tag = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^;date.timezone =.*$,date.timezone = Asia/Dhaka,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^display_errors =.*$,display_errors = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^expose_php =.*$,expose_php = Off,' /opt/alt/php72/usr/php/php.ini
- 至此,问题应该解决了。
欢迎转载《CWP7如何设置延长timeout limit?解决Nginx 504 Gateway错误》
欢迎分享本文链接:https://www.chenweiliang.com/cwl-30321.html
网站地址:https://www.chenweiliang.com/
欲获取更多资讯内幕和秘技,欢迎进入Telegram频道:https://www.chenweiliang.com/go/tgchannel
没有评论:
发表评论