Nginx. conf weight loss notes

Source: Internet
Author: User

Nginx. conf weight loss notes

The problem is that the nginx. conf file is too long, too large, and inconvenient to maintain. Therefore, you can split the file so that it is easy to read and maintain.

1. Remove all weixin configurations in nginx

As shown below, this is the configuration record in the nginx. conf configuration file and will become more and more in the future.

 location ~* ^/weixin_g1.*$ {           include deny.conf;           proxy_pass http://weixin_web_9600;           include proxy.conf;           error_log  logs/weixin_g1_error.log error;           access_log  logs/weixin_g1_access.log  main;           include gzip.conf;        }              location ~* ^/weixin_g2.*$ {           include deny.conf;           proxy_pass http://weixin_web_9600;           include proxy.conf;           error_log  logs/weixin_g2_error.log error;           access_log  logs/weixin_g2_access.log  main;           include gzip.conf;        }              location ~* ^/weixin_g3.*$ {           include deny.conf;           proxy_pass http://weixin_web_9600;           include proxy.conf;           error_log  logs/weixin_g3_error.log error;           access_log  logs/weixin_g3_access.log  main;           include gzip.conf;        }              location ~* ^/weixin_g4.*$ {           include deny.conf;           proxy_pass http://weixin_web_9600;           include proxy.conf;           error_log  logs/weixin_g4_error.log error;           access_log  logs/weixin_g4_access.log  main;           include gzip.conf;        }   
2. regenerate the weixin. conf file.

Vim nginx. conf
Then enter the edit line, enter 312,363 weixin. conf, and press enter to generate a new file, as shown below:

[root@nginx_service ~]# vim /tmp/nginx.conf 1 2 #user nginx nginx; 3 worker_processes 24; 4 5 #error_log logs/error.log; .......... 36 server 10.xx.1.211:8000 max_fails=5 fail_timeout=30s; 37 server 10.xx.1.212:6100 max_fails=5 fail_timeout=30s; 38 server 10.xx.1.215:7100 max_fails=5 fail_timeout=30s; 39 server 10.xx.1.216:7000 max_fails=5 fail_timeout=30s; 40 }:312,363 w 1.conf

PS: original blog address: http://blog.csdn.net/mchdba/article/category/910030 without the original csdn blogger mchdba allowed, declined to reprint.

3. Delete the original configuration section and import the new weixin. conf file.

Delete the old paragraph. In vim

: 312,363 d # indicates that all records from 312nd rows to 363rd rows are deleted. 330 331 proxy_pass http: // OCC_MAP_Web; 332 include proxy. conf;: 312,363 d

When the Enter key is executed, the system prompts that the deletion is successful, as shown below:

331 location ~ * ^/ParkingWeb/. * ${332 include deny. conf; fewer than 52 rows

And then add the weixin. conf configuration to the end.

 #weixin config include weixin.conf;
4. Restart nginx to make the new configuration take effect.
[nginx@nginx_service ~]$ service nginx reloadreload nginx[nginx@nginx_service ~]$ 
5. Some vim shortcut commands are attached.
Method 1 of Multiline deletion and replication in VI: Single Row deletion,: 1 (row to be deleted) d multiline deletion,: 1, 10 days Method 2: row where the cursor is located, dd: place the cursor in N rows below the row. Ndd Method 1: place the cursor in row 6th, input: 2yy place the cursor in row 9th, input: p This method is suitable for copying a small number of lines of text, copy two rows of data under 6th rows (including) and put them under 9th rows. Method 2: In command line mode, enter 6, 9 co 12 to copy the content between 6th rows and 9th rows to the end of 12th rows. Method 3: You can use tags to move the cursor to the starting line instead of reading a large number of rows or copying a large number of rows. Enter ma to move the cursor to the end line, and input mb to move the cursor to the paste line, enter mc and then: 'a, 'B co' c. Change co to m to cut the multi-line deletion. You can use: 5, 9 commonly used deVIM commands. 1) the cursor command k, j, h, l --- move the cursor from top to bottom. Although the four cursor keys on the right of the keyboard can be used in Linux, it is very useful to remember these four commands, that is, nG ---- n, the position of the right hand on the keyboard, is the number of rows. This command immediately redirects the cursor to the specified row. Ctrl + G ----- number of rows and columns at the cursor position report w, B ------ let the cursor forward or backward skip a word 2) EDIT command I, a, r ------- before the cursor, insert the character command above (I = insert, a = append, r = replace) cw, dw ------ change (replace) /command for deleting the word at the cursor position (c = change, d = delete) x, d $, dd ----- delete a character, all the characters from the cursor position to the end of the line, and the entire line of command 3) Find the command/string ,? String ----- command to find the corresponding string from the cursor to the back/forward 4) copy the Copy command yy, p ----- command FAQs and application tips for copying a row to the clipboard/getting the content from the clipboard 1) read the content in/etc/passwd in a new file and retrieve the vi file in the username section: r/etc/passwd read/etc/passwd: % s /:. * // g delete all parts after the username in/etc/passwd from the colon to the end of the line: 3r/etc/passwd this is to read the file content after the specified row number. Another method is to delete all the empty lines in the file and comment lines starting with # cat squid. conf. default | grep-v '^ $' | grep-v '^ #' 2) after opening a file and editing it, the logged-on user has no write permission for the file, you cannot save the vi file: w/tmp/1. Since you cannot save the disk, you do not want to give up all the modifications. Save to/tmp/1: 20, 59 w/tmp/1, or simply save the content between 20th and 59 rows into a file/tmp/13) Use VI to edit a file, however, you need to delete the contents of a large segment. vi file Ctrl + G move the cursor to the row to be deleted, press ctrl + G to display the row number, and then press Ctrl + G at the end.: 23,104 5d if the two row numbers are 23 and 1045, you can delete all the contents of the two rows. You can also use ma In the start and end lines, mark the mb command and use: 'A, 'bd Delete. 4) Add a string vi file at the beginning or end of the line to the entire file or several lines: 3, $ s/^/some string/insert some string before the beginning of the first line to the last line of the file: % s/$/some string/g add some string: % s/string1/string2/g at the end of each row of the entire file replace string1 with string2 in the entire file: 3, 7 s/string1/st Ring2/replace string1 in the third to seventh rows of the file into string2 Note: s is substitute, % Represents all rows, g Represents global 5) EDIT two files at the same time, copy and paste the text vi file1 file2 yy in two files, open two files at the same time, copy the row where the cursor of file 1 is located: n switch to file 2 (n = next) p paste the copied line at the cursor position of file 2: N switch back to file 16) Replace the path in the file: % s #/usr/bin # g replace all the paths/usr/bin in the file with/bin or use: % s // usr/bin // bin/g indicates '/' is a single character '/' 7 with a symbol before) if you want to annotate a multi-line program with a multi-line comment with vi, a stupid way is to insert #, and then use j to jump to the next line. command. Repeat the previous command. If you want to comment hundreds of lines, this method may be too stupid. A clever method is:., + 499 s/^/#/g. to insert the first line of the full text, run the following command: % s/^/#/g.

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.