Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-FPM和Nginx:“;“资源暂时不可用”;代理错误日志中的错误_Php_Linux_Apache_Nginx_Centos - Fatal编程技术网

PHP-FPM和Nginx:“;“资源暂时不可用”;代理错误日志中的错误

PHP-FPM和Nginx:“;“资源暂时不可用”;代理错误日志中的错误,php,linux,apache,nginx,centos,Php,Linux,Apache,Nginx,Centos,我发现了4年前发布的以下讨论: 有人和我有类似的问题,但不幸的是,我相信他收到的配置是为他自己的服务器规格定制的,我不能在我的服务器上使用相同的配置。无论如何,我想提出我自己的问题,而不是告诉你去我发送的链接,阅读别人的问题 我有一个很大的社交媒体页面,我在那里发布我网站文章的链接,这意味着我每天分享东西时都会有很多流量高峰。最近,我注意到该网站速度太慢,有时根本无法加载。不幸的是,我对解决此类问题不太熟悉,而且我没有一位系统管理员来管理我的专用服务器,因为我是从OVH租来的,OVH提供低成本的

我发现了4年前发布的以下讨论:

有人和我有类似的问题,但不幸的是,我相信他收到的配置是为他自己的服务器规格定制的,我不能在我的服务器上使用相同的配置。无论如何,我想提出我自己的问题,而不是告诉你去我发送的链接,阅读别人的问题

我有一个很大的社交媒体页面,我在那里发布我网站文章的链接,这意味着我每天分享东西时都会有很多流量高峰。最近,我注意到该网站速度太慢,有时根本无法加载。不幸的是,我对解决此类问题不太熟悉,而且我没有一位系统管理员来管理我的专用服务器,因为我是从OVH租来的,OVH提供低成本的非托管服务器。服务器有很好的规格,即使站点上有100个活动用户,这个问题也会发生。我还可以在服务器日志中看到一些错误

服务器规格如下所示:

AMD Opteron(tm)处理器4334,AMD Opteron(tm)处理器4334(6核)

SoftRaid 3x160GB SSD

32GB内存

1Gbps连接

CentOS x64 Linux 7.2.1511版(核心版)

普莱斯克v12.5.30


我所说的错误是:

代理错误日志

2016/10/02 09:49:36 [error] 6931#0: *469804 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750"
2016/10/02 09:49:36 [error] 6931#0: *469806 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000"
2016/10/02 09:49:38 [error] 6931#0: *469826 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 73.77.251.156, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:38 [error] 6931#0: *469830 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 217.123.129.73, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469840 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500"
2016/10/02 09:49:39 [error] 6931#0: *469842 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2605:6001:f08a:3400:88d6:8b94:4499:8e36, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469845 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 162.158.75.61, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469847 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000"
2016/10/02 09:49:39 [error] 6931#0: *469849 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875"
2016/10/02 09:49:39 [error] 6931#0: *469851 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2601:81:4203:1bce:5809:b94c:4616:4730, server: ###.com, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/###/"
2016/10/02 09:49:40 [error] 6931#0: *469853 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2602:306:8b97:11a0:6843:ad77:251e:864a, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
我有很多这样的^


我现在将附加一些配置文件,就像我链接到的另一个线程中的家伙一样,这样您就可以了解我的服务器上发生了什么

php fpm.conf

include=/etc/php-fpm.d/*.conf

[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
[www]

listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln

listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660

chdir = /

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1

catch_workers_output = yes

php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
worker_processes  1;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

/etc/php fpm.d/www.conf

include=/etc/php-fpm.d/*.conf

[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
[www]

listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln

listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660

chdir = /

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1

catch_workers_output = yes

php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
worker_processes  1;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

/etc/php fpm.d/#####com.conf

include=/etc/php-fpm.d/*.conf

[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
[www]

listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln

listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660

chdir = /

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1

catch_workers_output = yes

php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
worker_processes  1;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

sysctl.conf

include=/etc/php-fpm.d/*.conf

[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
[www]

listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln

listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660

chdir = /

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1

catch_workers_output = yes

php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
worker_processes  1;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

/etc/nginx/nginx.conf

include=/etc/php-fpm.d/*.conf

[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
[www]

listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln

listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660

chdir = /

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1

catch_workers_output = yes

php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
worker_processes  1;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

/etc/security/limits.conf没有配置,里面只有注释


以下是以下命令的结果:

ulimit -n
1024

ulimit -Sn
1024

ulimit -Hn
4096

cat /proc/sys/fs/file-max
3266168

free -m
              total        used        free      shared  buff/cache   available
Mem:          32089        1284        3784        1718       27020       28936
Swap:          1532           1        1531

关于快速CGI_参数-我不知道在Plesk的哪里可以找到这个。我只能找到一个包含我不知道其值的变量的文件。 例如,如以下几行(整个文件就是这样的):


我很抱歉,如果有什么遗漏,我真的试图使它尽可能详细,它也不容易找到配置文件的位置与普莱斯克。我必须对上面所附的每个文件做一些研究。。。(老实说,这是我不喜欢普莱斯克的原因之一,但这正是我所拥有的)

如果您还有任何配置文件需要我发送,请让我知道,我将在评论中附上它。还请告诉我在哪里可以找到它们(考虑到我使用的是Plesk v12.5)。 对我来说,根据我的需要和规格正确配置服务器并消除错误非常重要,因此请帮助我。:)


谢谢大家!

尝试增加php fpm子项的数量,例如:

pm.max_children = 30
pm.start_servers = 10
pm.min_spare_servers = 3
pm.max_spare_servers = 15

那么突然的流量峰值不会产生错误

我也有这个问题。重新启动fpm修复了它

sudo服务php7.1-fpm重启


更改php版本。

您确定吗?是的,这降低了出错的几率,但它们会突然消失吗?如果我将您的服务器置于非常高的负载下,您的解决方案是否仍然有效?也,OP询问将配置放置在何处这取决于服务器CPU,需要进行测试。当然,大型pm.max_子项会增加CPU消耗。参数转到/etc/php fpm.d/####。conf解释了如何根据应用程序的需要和服务器规格确定正确的max#子项数量,而有时什么都不起作用重新启动服务可能会起作用。但这不是正确的解决方案。一个人应该找到问题的根本原因并解决它。为我工作的所有其他解决方案都失败了,在生产中不是一个可接受的解决方案。