In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Preface Nginx as a load balancing server: Nginx can not only directly support Rails and PHP programs to serve outside, but also support external services as a HTTP proxy server. Nginx is written in C, both the system resource overhead and the efficiency of CPU are much better than Perlbal.
Handle static files, index files, and automatic indexing; turn on file descriptor buffering.
Reverse proxy acceleration without caching, simple load balancing and fault tolerance.
FastCGI, simple load balancing and fault tolerance.
Modular structure. Including gzipping, byte ranges, chunked responses, and SSI-filter and other filter. If FastCG or another proxy server processes multiple SSI that exist in a single page, the process can be run in parallel without waiting for each other. 1. Check the basic information of the version curl-I http:// 's own IP address
2. Add the configuration file of Nginx: the value of the server_tokens option is set to offvim / usr/local/nginx/conf/nginx.confhttp {add a paragraph under include mime.types; default_type application/octet-stream;#, and close the version to display server_tokens off.
3. Restart the service / / disable the service first, then enable the service service nginx stopservice nginx start4, and then use the curl command to check the version
1.2.Modification source code method Nginx source code file / pot/nginx-1.12.0/src/core/nginx.h contains version information, you can set recompile and install at will, hide version information 1, modify version number # first off (close) the paragraph you just added Change to on (open) vim / usr/local/nginx/conf/nginx.confcd / opt/nginx-1.12.2/src/core/vim / opt/ningx-1.12.2/src/core/nginx.hdefine nginx_version 1012002define NGINX_VERSION "1.1.1" / / Custom a version number define NGINX_VER "nginx/" NGINX_VERSION
2. Configure and compile cd nginx-1.12.2/./configure\-- prefix=/usr/local/nginx\-- user=nginx\-- group=nginx\-- with-http_stub_status_modulemake & & make install3, start the service, and view the version # when viewing the startup service service nginx stopservice nginx start#, you will find that there is a forged version number curl-I http://IP address / Sercer: nginx/1.1.1 # forged version number
Note: if the version number is not forged successfully and does not display, it is possible that the version display is turned off in the configuration file. Solution: delete server_tokens off Second, modify Nginx users and groups Nginx runtime process requires the support of users and groups to achieve access control when reading website files Nginx default use nobody user account and group account, generally also need to modify the method: compile and install to specify users and groups to modify the configuration file to specify users and groups 2.1, modify the configuration file to specify users and groups vim / usr/local/nginx/conf/nginx.conf#user nobody / / remove the previous comment character "#" and modify nobody to specify user and group nginx nginx
The main process is created by root and the child process is created by nginx. 3. Configure the Nginx web page cache time when Nginx returns the web page data to the client, the cache time can be set to facilitate direct return in future requests for the same content, avoid repeated requests, and speed up the access speed. Generally, it is set for static web pages. Do not set cache time for dynamic web pages can use fiddler in the Windows client to view page cache time setting method: can modify the configuration file Add an expiration parameter 1 for a specific content in the http section, or the server segment, or the location segment. Copy a picture to the nginx site directory # find "game.jpg" in your shared file mkdir / abcmount.cifs / / 192.168.56.1/lamp7 / abccd / abc/wl// my picture is in the wl package / / copy the picture game.jpg to the site directory cp / abc/wl/game.jpg / usr/local/nginx/html/cd / usr/local/nginx/html
2. Add the picture to the page content # modify the vim index.html# and add a paragraph below the Welcome to nginx
3. Change the configuration file vim / usr/local/nginx/conf/nginx.conf# of nginx to the section http {}, and add a location ~\. (gif | jepg | jpg | ico | bmp | png) ${root html; expires 1d;}
4. Start the service # restart the service service nginx restart5 and verify in win10
Configure log segmentation as the running time of Nginx increases, the log will also increase. In order to easily grasp the running status of Nginx, it is necessary to always pay attention to the fact that the Nginx log file is too large for monitoring is a catastrophe. Nginx does not have the function of log segmentation, but it can realize automatic log cutting through the script of Nginx signal control function. And periodically cut the log through the planned task of Linux, write a script to cut the log: set the time variable, set the path to save the log Rename the current log file and delete the log file for too long to set up the cron task Regular execution of scripts for automatic log segmentation. 1. Write a script to split the vim / optlogs_path= pid_path= / var/log/nginx pid_path= / usr/local/nginx/logs/nginx.pid [- d $logs_path] | | mkdir-p $logs_pathmv / usr/local/nginx/logs/access.log ${logs_path} / test.com-access.log-$dkill-USR1 $(cat $pid_path) find $logs_path-mtime + 30 | xargs rm-rf
2. Execute the script chmod + x fenge.sh./fengs.sh// to modify the current time to 2019.12.29, (can be customized) date-s 2019-12-29
3. Set cron tasks, execute regular scripts to automatically split logs and execute periodic planned tasks crontab-e01 * / opt/fengs.sh 5. Realize connection timeout in corporate websites, in order to avoid long-time connections with customers, resulting in a waste of resources You can set the corresponding connection timeout parameter to control the connection access time. Use the Fiddler tool to view the connection parameter timeout parameter explanation: Keepalive_timeout sets the connection to maintain the timeout. Generally, you can only set this parameter. The default is 75 seconds. It can be set according to the situation of the website, or closed. You can set Client_header_timeout in the http segment, server segment, or location segment to specify the timeout for waiting for the client to send the request header Client_body_timeout sets the request body reading timeout 1, modify the configuration file cd / usr/local/nginx/conf vim nginx.conf# in the http {} segment: add keepalive_timeout 65 180 below Client_header_timeout 80th clientele bodybuilding timeout 80transferable / restart service service nginx restart
Verify with fidder in win10.
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.