最近进入VPS系统并安装它们,等等等等。所以,我有一对夫妇工作的网站,其中一个我试图真正优化它的速度。 使用雅虎的ySlow作为指导,我仍然没有gzip和标题过期部分。 我的nginx.conf位于/etc/nginx/nginx.conf,这里是它的细节:
请帮忙! 我不知道为什么它不工作。
####################################################################### # # This is the main Nginx configuration file. # # More information about the configuration options is available on # * the English wiki - http://wiki.codemongers.com/Main # * the Russian documentation - http://sysoev.ru/nginx/ # ####################################################################### #---------------------------------------------------------------------- # Main Module - directives that cover basic functionality # # http://wiki.codemongers.com/NginxMainModule # #---------------------------------------------------------------------- user www www; worker_processes 2; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; #---------------------------------------------------------------------- # Events Module # # http://wiki.codemongers.com/NginxEventsModule # #---------------------------------------------------------------------- events { worker_connections 1024; } #---------------------------------------------------------------------- # HTTP Core Module # # http://wiki.codemongers.com/NginxHttpCoreModule # #---------------------------------------------------------------------- http { include /etc/nginx/mime.types; default_type application/octet-stream; client_max_body_size 10M; client_body_buffer_size 128k; log_format main ' - [] ' '"" "" ' '"" ""'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 20; tcp_nodelay on; # Load config files from the /etc/nginx/conf.d directory include /etc/nginx/conf.d/*.conf; # # The default server # server { listen 443; server_name 127.0.0.2; ssl on; ssl_certificate /etc/nginx/sslconf/server.crt; ssl_certificate_key /etc/nginx/sslconf/server.key; location /phpmyadmin { root /usr/html; index index.php; gzip on; gzip_http_version 1.1; gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js; gzip_buffers 16 8k; location ~* \.(jpg|png|gif|jpeg|css|js)$ { expires 1h; } } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name; fastcgi_param HTTPS on; } } server { listen 80; server_name 127.0.0.2; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/html; index index.html index.htm index.php; } location = /phpmyadmin/ { rewrite ^ https://127.0.0.2$uri redirect; } error_page 404 /404.html; location = /404.html { root /usr/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name; } #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } # Load virtual host configuration files. include /etc/nginx/sites-enabled/*; }
从http://wiki.nginx.org/HttpGzipModule
gzip on; gzip_min_length 1000; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain application/xml; gzip_disable "MSIE [1-6]\.";
从http://wiki.nginx.org/HttpHeadersModule
expires 24h; expires modified +24h; expires @15h30m; expires 0; expires -1; expires epoch; add_header Cache-Control private;
看来,这些选项中的一些存在于您的phpmyadmin区域,但不在您的主要网站configuration。