Nginx服务文件真的很慢

时间:2014-11-24 21:14:26

标签: nginx

我遇到的问题是Nginx服务文件的速度非常慢。最终,我的应用程序加载缓慢,但是,为了缩小问题范围,我获取了所有生成的HTML,并将其保存到文件中,并且一直使用Apache的基准测试来拉取该html文件。这就是ab的平均运行情况:

debian@localhost:/var/www/resources/laravel$ ab -n 5 -H "Accept-Encoding: gzip,deflate" http://lnp2.moveyourmountain.org/test1.html | grep -A 5 Connection
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       74  101  32.4    101     152
Processing:  1556 2315 431.6   2484    2622
Waiting:       74   79   7.2     77      91
Total:       1630 2416 450.1   2579    2774

所以,这就是我认为这是Nginx的问题。我不完全确定要发布什么配置,所以我想我会发布nginx.conf和我的网站启用配置。

nginx.conf

user  www-data;
worker_processes 4;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;  # don’t use SSLv3 ref: POODLE

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$http_x_forwarded_proto -- $remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for" - $request_time';

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

    #sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;
    gzip_disable "msie6";
    gzip_comp_level 5;
#    gzip_proxied any;
#    gzip_vary on;
#    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
#    gzip_types text/plain text/css application/json application/javascript         application/x-javascript text/xml application/xml application/xml+rss text/javascript;

     fastcgi_buffers 32 32k;
     fastcgi_buffer_size 32k;

    index index.php index.html index.htm;
    include /etc/nginx/conf.d/*;

#    server {
#        listen 127.0.0.1:80;
#        server_name 127.0.0.1;
#        location /nginx_status {
#            stub_status on;
#            allow 127.0.0.1;
#            deny all;
#        }
#    }
}

网站启用配置

server {
        client_max_body_size 10M;
        listen  80; ## listen for ipv4; this line is default and implied

        #if ($http_x_forwarded_proto = "http") {
    #        return 301 https://moveyourmountain.org$request_uri;
        #}

        root /var/www/sites/moveyourmountain.org/;

        # Make site accessible from http://localhost/
        server_name moveyourmountain.org www.moveyourmountain.org lnp2.moveyourmountain.org;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params_ssl;
        }

        location /help {
                try_files $uri $uri/ /help/index.php?q=$uri&$args;
        }

        location /blog {
                try_files $uri $uri/ /blog/index.php?q=$uri&$args;
        }

        #location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        #       expires 1y;
        #}
}

我道歉,我的配置有点奇怪&凌乱,我已经为此工作了几天,尝试了我能找到的一切。此外,由于我已经阅读了一些案例,当他们的服务器重新启动时,它很快就有一段时间了,我试过了。它没有改变任何东西,速度仍然是相同的。

0 个答案:

没有答案