Articles of php fpm

FastCGIcaching总是一个MISS

所以,我已经设置FastCGIcaching像这样: location ~ \.php(/.*)?$ { fastcgi_cache RWI; fastcgi_cache_valid 200 60m; set $nocache 0; if ($request_method = POST) { set $nocache 1; } if ($http_cookie ~ (rwi_userid*|rwi_password*)) { set $nocache 1; } if ($request_uri ~* "/(vb/admincp/)") { set $nocache 1; } fastcgi_no_cache $nocache; fastcgi_cache_bypass $nocache; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass "unix:/var/www/vhosts/system/{domain}/php-fpm.sock"; include /etc/nginx/fastcgi.conf; } 在server{}块的顶部,我有: […]

Nginxcaching符号链接

我的Web服务器上有一个部署系统,每次部署一个应用程序时,它会创build一个新的时间戳目录,并将“当前”符号链接到新目录。 在apache上这一切都很好,但是在我设置的新的nginx服务器上,它看起来像是一个来自“旧”部署的脚本,而不是新的符号链接的脚本。 我已经阅读了一些教程和post,如何解决这个问题,但没有太多的信息,似乎没有任何工作。 这是我的虚拟主机文件: server { listen 80; server_name ~^(www\.)?(?<sname>.+?).testing.domain.com$; root /var/www/$sname/current/public; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) { add_header Cache-Control public; add_header Cache-Control must-revalidate; expires 7d; } location ~ \.php$ { #fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; include fastcgi_params; fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; […]

Nginx和PHP-FPM,随机的502

2010/09/19 14:52:07 [error] 1419#0: *10220 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: […], server: […], request: "POST /[…] HTTP/1.1", upstream: "fastcgi://unix:/server/php-fpm.sock:", host: "[…]", referrer: "[…]" 这是我随机收到的错误。 95%的时间我的设置完美的工作,但有一段时间,我得到了502 3-4的后续请求。 正如你所看到的,我在服务器和PHP进程之间使用了Unix套接字,也正确设置了FastCGI params(SCRIPT_FILENAME)等。 我能做些什么来加强这些服务之间的联系? 非常感谢你提前。

优化NGinx + PHP-FPM

我目前在我的服务器上为我的网站运行Nginx + PHP-FPM。 今天当我运行Apache“ab”工具时,我注意到可怕的响应时间,平均5595和最大17415毫秒的响应。 我的Nginxconfiguration文件: worker_processes 4; error_log /var/log/nginx/error.log info; events { worker_connections 1024; use epoll; multi_accept on; } http { server_name_in_redirect off; server_names_hash_max_size 10240; server_names_hash_bucket_size 1024; include mime.types; default_type application/octet-stream; index index.html index.htm index.php; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; gzip on; gzip_vary on; gzip_disable "MSIE [1-6]\."; gzip_proxied any; gzip_http_version […]

服务器上的内存使用量过高 – 无法确定进程

我注意到服务器上的内存使用率很高。 细节: 操作系统:CentOS 6.3 – x86_64 Web服务器:带有PHP-FPM的Nginx 服务器正在生成PDF文档,所以stream量是最小的。 最佳: # top -b -n 1 -a top – 10:04:51 up 21 days, 18:57, 1 user, load average: 0.00, 0.00, 0.00 Tasks: 92 total, 1 running, 91 sleeping, 0 stopped, 0 zombie Cpu(s): 0.3%us, 0.2%sy, 0.0%ni, 99.6%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 3923092k total, 3720380k used, 202712k […]

停止使用PHP-FPM为不同站点重用PHP_VALUE

我注意到以下行为或PHP-FPM: 看看这两个Nginx的configuration: server { listen 80; server_name example.com; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /srv/www/i.php; fastcgi_param PHP_VALUE "display_errors=1"; include fastcgi_params; } } server { listen 80; server_name example.net; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /srv/www/i.php; include fastcgi_params; } } 和/srv/www/i.php文件: <?php phpinfo(); 正如你可以看到唯一的区别是fastcgi_param PHP_VALUE "display_errors=1"; 。 现在,如果您杀死所有FPM工作者,并首先打开example.net ,您将会看到display_errors Off 。 在example.com你会看到display_errors为On 。 但是如果你再次访问example.net […]

php-fpm php_network_getaddresses调用随机启动失败,坏udp cksum

我们在AWS上的ubuntu实例上运行了许多Web服务器(nginx,php5.6-fpm)。 他们已经运行好几个月了,但是在过去的几天里,我们已经开始讨论一个事件发生后一切正常,但在12个小时左右之后,networking调用开始失败(特别是在这个实例套接字tcp调用redis)。 在使用tcpdump进行了一些挖掘之后,由于udp校验和失败,看起来dns查找被抛出: 17:13:38.013346 IP(tos 0x0,ttl 64,id 46236,offset 0,flags [DF],proto UDP(17),length 103)10.0.0.121.34071> 10.0.0.2.53:[bad udp cksum 0x14df – > 0x3ae1!] 25855+ Type20736? xxxxxxxx.us-east-1.rds.amazonaws.com。 (75) 如果我使用telnet从同一个实例连接到Redis服务器,那么很好,它似乎只影响fpm。 同样奇怪的是,它只是在实例开始后才发生 – 最初的所有请求都没有问题。 同样,重新启动php5.6-fpm服务似乎已经清除了一段时间的问题。 在这一点上,我的知识基本已经结束了,所以希望有人能指出我正确的方向!

如何添加池到FPM(nginx)没有重新加载/重新启动fpm本身?

我build立一个环境(在Ubuntu 10.04.02机器上)处理一个网站与许多(应该至less支持1000)子域,其中每个子域,由不同的FPM池,与不同的用户。 没有什么新鲜的 我的问题是创build(和启动)一个新的FPM池,而不必重新加载/重新启动FPM,这将导致(我知道,非常快)的停机时间。 我写了一个python守护进程,当需要的时候: 创build系统用户 设置子域的Web根目录 创buildsubdomain.conf到我的/etc/php5/fpm/fpm.d/文件夹中 我search了一下,但我没有find一种方法来调用fpm使用一个池,这可能是一个'临时'的解决scheme:主要的fpm实例运行所有的池,evey新的获得自己的fpm实例,然后用cron停止,每周/每月/ dontknowyet重新加载fpm 如果没关系,服务器运行在nginx上,configuration为使用unix socket到fcgi,这是我的nginxtestingconfiguration: server{ listen 80; server_name ~^(?<domain>.+)\.test\.local$; # foo.test.local > myapp_foo root /var/www/myapp/subdomains/myapp_$domain/htdocs; location / { index index.php; } location ~* \.(gif|jpg|png|ico)$ { expires 30d; } location ~ \.php$ { fastcgi_pass unix:/var/web-sock/myapp_$domain-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ..和我的子域 – fpm.conf: [myapp_foo] listen = […]

用nginx chrooting php-fpm

我使用PHP 5.3.9和nginx设置了一个新的服务器,所以我使用php-fpm SAPI选项编译了PHP。 本身在nginx中使用以下服务器条目效果很好: server { listen 80; server_name domain.com www.domain.com; root /var/www/clients/domain.com/www/public; index index.php; log_format gzip '$remote_addr – $remote_user [$time_local] "$request" $status $bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"'; access_log /var/www/clients/domain.com/logs/www-access.log; error_log /var/www/clients/domain.com/logs/www-error.log error; location ~\.php$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/clients/domain.com/www/public$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include /etc/nginx/fastcgi_params; } } 它服务器我的PHP文件就好了。 为了增加安全性,我想chroot我的FPM实例,所以我在这个FPM实例的conf文件中添加了以下几行: # FPM config chroot […]

哪个php5-fpm设置为高并发连接数+ nginx

请帮我调整我的configuration为php5-fpm和nginx。 问题是我的php5-fpm日志不断报告缓慢的脚本和杀死一个子线程。 专用服务器,四核xeon,32Gb Ram。 1 php应用程序/网站运行。 Php应用程序:果壳,search引擎,结果消防curl请求。 页面加载时间通常是每个search2-3秒。 这是我认为正在发生的事情我得到750个并发的php用户执行search。 由于内存限制,我只能设置pm.max_children = 400。 我假设每个用户50Mb(子线程),使得= 20GB。 我假设每个用户= 1个子线程。 所以,pm.max_children不足以覆盖正在进行search需要3秒钟的750个活跃的php用户。 所以我认为我看到用户排队,因为我看到3秒变成4 – 7秒。 作为用户排队,我认为脚本越来越慢触发错误日志消息和php5-fpm下午杀死孩子? 这是我认为正在发生的事情。 我在下面提供了我的错误日志输出,nginx,php5-fpm config。 我真的很感激任何意见,如果我可以调整我的configuration,如果pm.max_children应该至less等于你最大并发用户,请记住,我的PHPsearch打开约3秒。 我是否需要更多的内存或更多的服务器? 这是我的记忆,但是我只在30分钟前重启了nginx :/var/log# free -m total used free shared buffers cached Mem: 32151 26175 5975 0 186 13334 -/+ buffers/cache: 12654 19496 Swap: 32739 5 32734 php5-fpm:www.conf:进程pipe理器被设置为静态 我使用静态的,因为我认为所有的孩子将立即可用,而不是产卵时间,我只在箱子上运行1个应用程序。 ;pm = […]