Nginx cache settings, compression configuration, and automatic column directory configuration for Linux systems

Source: Internet
Author: User
Tags nginx server

(All CentOS system commands in this article are represented by Italic bold, so you can read it)

Attention! I use LNMP script mode installation of Nginx 1.8.0 stable version, if it is downloaded from the official website version, nginx.conf configuration file a little different, but the skeleton is identical, do not delay reading.


Cache Settings

Nginx server caching capability is still worth certain, the server cache means that the Web cache is located between the content source Web server and the client, when the user accesses a URL, the Web cache server will go to the backend Web source server to retrieve the content to output, and then, when the next request arrives, If you are accessing the same Url,web cache server directly output the content to the client, instead of sending the request to the source server again. Web caching reduces the load on the content source Web server, the database, reduces network latency, improves the responsiveness of user access, and enhances the user experience.


It is still the conf/nginx.conf file that enters the Nginx installation path.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/79/C2/wKioL1aaZqaRU6CaAABhKJ2cE1o352.png "title=" Screenshot-2.png "alt=" Wkiol1aazqaru6caaabhkj2ce1o352.png "/>

The red box is the cache configuration, which first configured all the suffix name is gif\jpg\jepg\png\bmp\swf files can be stored in the server cache for 30 days.

The English meaning of expire is "expiry, agreement expires, expired, dies".

All files with suffix js\css are then configured to be stored in the buffer for 12 hours, and finally all other types of files are rejected. This is the basic format, which can be modified according to the actual needs.


Compression configuration

The compression configuration is just a bit above the cache configuration,

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/79/C3/wKioL1aaZ-rBdKeTAABBbIGHEsk221.png "title=" Screenshot-3.png "alt=" Wkiol1aaz-rbdketaabbbighesk221.png "/>gzip on: Compression is in the way of gzip, and the compression mode is turned on.

Gzip_min_length 1k: Compressed minimum file size is 1K, after all, if more than 1K, may compress the file is larger than the original file, because the compression is to give the source file header and tail.

Gzip_buffer 4 16K: The original file compression result request memory size is 4 16K.

The HTTP protocol identified by Gzip_http_version 1.1:gzip is version 1.1.

Gzip_vary on: Open to determine if the client also supports GZIP, and if the client does not support gzip, then it will not be compressed.


Automatic Column directory Configuration

Access to the server's URL, by default there is a index.html waiting, and if the file changes, then the default will prompt 404 forbidden, but if you want to display the Index.html folder other files, you need to turn on "Automatic column directory configuration."

Enter the nginx.conf Master profile,

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/79/C4/wKioL1aaaYPSzVLhAAAzdPxxve8473.png "title=" Screenshot-4.png "alt=" Wkiol1aaaypszvlhaaazdpxxve8473.png "/>

Here write out the default port is 80, server name and home page, first place is index.html, if there is no this first file, then go to find index.htm, if the second is not, then third, index.php.

This adds autoindex on, which means to turn on the Automatic column directory feature.

Then is the path labeled First page index.html, save the path as shown in the file is/home/wwwroot/default.

Since already joined the AutoIndex on, then can be the original rank 123 "three-in-the-dust" changed the name or directly deleted, I chose the name, changed to Index1.html, the back of the two and three directly deleted. Open the browser and enter the IP address. The contents of the Index.html directory should appear, that is, the contents of the/home/wwwroot/default directory:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/79/C4/wKioL1aaayqRewRiAABFuZjigsg192.png "title=" Screenshot-5.png "alt=" Wkiol1aaayqrewriaabfuzjigsg192.png "/> Here, there are two folders in the directory, a call 222, a call phpMyAdmin, and several other files, such as indexex.html, and so on, if you want to see the contents of the 222 folder, directly Click 222, such a effect is a bit similar to the Ftp,vim type of file can be directly online left click to watch, and tar.gz this can be directly downloaded.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/79/C8/wKioL1aaeLCRIebtAACb67g319E587.png "title=" Screenshot.png "alt=" Wkiol1aaelcriebtaacb67g319e587.png "/>

Those mirrors site is how to build, I think we should all understand it ~ ~

This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1735715

Nginx cache settings, compression configuration, and automatic column directory configuration for Linux systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.