nginx php访问缓慢,重定向 – Nginx Php-fpm的延迟问题

我有一个PHP应用程序,曾经在Apache上运行我刚刚切换到nginx.

我的php应用程序有一个php路由器,所以对于某些页面,流程就像是:

>您想要访问www.example.com

>由于您已登录,因此php会将重定向301发送到/ user / home.

使用Apache,php重定向在几百毫秒内完成,而使用nginx需要~2秒!

php重定向funtcion:

public function redirect($url, $code = 301)

{

if($code) {

$codeHeader = false;

switch ($code) {

case 301:

$codeHeader = "HTTP/1.1 301 Moved Permanently";

break;

}

if($codeHeader){

header($codeHeader);

}

}

header("Location: $url");

exit;

}

我的nginx.conf:

user www-data;

worker_processes 8;

pid /var/run/nginx.pid;

events {

worker_connections 2048;

multi_accept on;

use epoll;

}

http {

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 30;

reset_timedout_connection on;

client_body_timeout 10;

server_tokens off;

include /etc/nginx/mime.types;

default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] '

'"$request" $status $body_bytes_sent '

'"$http_referer" "$http_user_agent"';

access_log /var/log/nginx/access.log main buffer=16k;

error_log /var/log/nginx/error.log crit;

gzip on;

gzip_min_length 10240;

gzip_proxied expired no-cache no-store private auth;

gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;

gzip_disable "MSIE [1-6]\.";

application/xml application/xml+rss text/javascript;

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

include /etc/nginx/sites-enabled/*;

}

我的应用程序vhost:

server {

listen 80;

root /srv/www/example;

server_name www.example.com;

access_log /var/log/nginx/access.example.log;

error_log /var/log/nginx/error.example.log;

index /index.php;

location / {

try_files $uri $uri/ /index.php?q=$uri&$args;

}

location ~ \..*/.*\.php${

return 403;

}

# Block hidden files

location ~ (^|/)\. {

return 403;

}

location ~ \.(php|phtml)${

try_files $uri =404;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass_header X-Real-IP;

fastcgi_pass_header X-Forwarded-For;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PHP_VALUE "error_log=/var/log/nginx/error.example.log";

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi_params;

}

}

谁知道滞后来自哪里? ?

更新:

它可能确实是一个php-fpm问题所以这是我的php-fpm.conf(我删除了评论)

[global]

pid = /var/run/php5-fpm.pid

error_log = /var/log/php5-fpm.log

include=/etc/php5/fpm/pool.d/*.conf

还有我的www池

user = www-data

group = www-data

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 10

pm.start_servers = 4

pm.min_spare_servers = 2

pm.max_spare_servers = 6

chdir = /

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值