In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces an example analysis of the optimal configuration of Nginx services, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
1. Expires cache module
For specific configuration, please refer to the official document http://nginx.org/en/docs/http/ngx_http_headers_module.html#expires.
[root@cairui conf] # cat nginx.conf | egrep-v "# | ^ $" user nginx;worker_processes 1: events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server {listen 80; server_name localhost; location / {root html; index index.html index.htm;} location ~. *\. (gif | jpg | jpeg | bmp | swf | js | html | htm | css) ${log_not_found off; expires 7d Access_log off; proxy_store on; proxy_store_access user:rw group:rw all:rw;} error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root html } [root@cairui conf] # curl-I http://120.25.255.87/1.jpgHTTP/1.1 200 OKServer: nginx/1.13.9Date: Mon, 05 Mar 2018 04:08:41 GMTContent-Type: image/jpegContent-Length: 48561Last-Modified: Wed, 29 Nov 2017 08:16:39 GMTConnection: keep-aliveETag: "5a1e6ce7-bdb1" Expires: Mon, 12 Mar 2018 04:08:41 GMTCache-Control: max-age=604800Accept-Ranges: bytes
2. Nginx Compression Module (gzip)
Configure the compression module
[root@localhost vhost] # vi www.vhostsserver {listen 8001 / serverroomname 192.168.1.3 position location / {root / web/www;index index.html index.htm;access_log / application/nginx/log/access_www.log commonlog;} location. *\. (gif | jpg | jpge | png | bmp | swf) ${expires 3560dash root / web/www;} location. *\. (js | css)? ${expires 30dscape root / web/www;} gzip on; # enable the compression function gzip_min_length 1k # set the minimum number of bytes allowed to compress pages gzip_buffers 4 16kb * * gzipsets httppages version 1.0 * * gzippages compactness level 2 * * gzipcategories types text/plain application/x-javascript text/css application/xml;gzip_vary on;}
Check syntax, restart services
[root@localhost vhost] # / application/nginx/sbin/nginx-tnginx: the configuration file / application/nginx-1.10.1/conf/nginx.conf syntax is oknginx: configuration file / application/nginx-1.10.1/conf/nginx.conf test is successful [root@localhost vhost] # / application/nginx/sbin/nginx-s reload [root@localhost vhost] # cd / web/www/ [root@localhost www] # lltotal 12Murray 1 root root 20 Sep 26 07:00 index.html-rw-r--r--. 1 root root 5798 Sep 19 06:46 mysql.jpg [root@localhost www] # rzrz waiting to receive.Starting zmodem transfer. Press Ctrl+C to cancel.Transferring 1.js.100% 42 KB 42 KB/s 00:00:01 0 Errors? [root@localhost www] # lltotal 56 RW Murray. 1 root root 43978 Sep 27 05:06 1.jsMurray RWMurray Rafael Murray. 1 root root 20 Sep 26 07:00 index.html-rw-r--r--. 1 root root 5798 Sep 19 06:46 mysql.jpg client access http://192.168.1.3:8001/1.js[root@localhost www] # curl-I http://192.168.1.3:8001/1.jsHTTP/1.1 200 OKServer: nginx/1.10.1Date: Tue, 27 Sep 2016 04:44:08 GMTContent-Type: application/javascriptContent-Length: 43978Last-Modified: Tue, 27 Sep 2016 02:06:23 GMTConnection: keep-aliveETag: "57e9d41f-abca" Expires: Thu 27 Oct 2016 04:44:08 GMTCache-Control: max-age=2592000Accept-Ranges: bytes Thank you for reading this article carefully I hope the article "sample Analysis of optimal configuration of Nginx Services" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.