In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The Origin and Development of 1Magne Nginx
Nginx ("engine x") is a high-performance HTTP and reverse proxy server. Nginx was developed by Igor Sysoev (Igor Sessoyev) for the second most visited Rambler.ru site in Russia, and the first public version 0.1.0 was released on October 4, 2004.
Nginx is a lightweight Web server / reverse proxy server and e-mail (IMAP/POP3) proxy server for use by Russia's large portal and search engine Rambler. It is characterized by less memory and strong concurrency.
Chinese mainland uses Nginx website users: Baidu BWS, Sina, NetEase, Tencent and so on.
Nginx's official website: http://Nginx.org/en/download.html
Tengine:Tengine is a Web server project initiated by Ali. On the basis of Nginx, it adds a lot of advanced functions and features to meet the needs of high-volume websites. The performance and stability of Tengine have been well tested in large websites such as Taobao and Tmall Mall.
(it can be understood like this: Taobao got the Nginx source code, filled in, optimized, and so on, and then submitted it to the Nginx official, but due to the Nginx official response is slow or unresponsive, coupled with the language communication is not smooth, so Taobao company on their own packaging, in accordance with the principles of GPL for secondary development, out of the current version of Tengine).
Official website: http://tengine.taobao.org/
2the version information of MagneNginx
Mainline version mainline version
Stable version stable version (generally used, stable, less BUG)
Legacy versions Legacy version / Historical version
3The comparison between Apache and Nginx.
Advantages of Nginx over Apache:
Lightweight, the same as web services, take up less memory and resources than Apache; high concurrency, Nginx processing requests are asynchronous non-blocking, while Apache is blocking, Nginx can maintain low resources, low consumption and high performance under high concurrency; highly modular design, relatively simple to write modules; active community, a variety of high-performance modules produced quickly.
Advantages of Apache over Nginx:
Rewrite is more powerful than Nginx's rewrite; there are so many modules that you can find almost everything you can think of; with less BUG, there are relatively more BUG in Nginx; the existence of hyperstability is the reason. Generally speaking, use Nginx for web services that require performance. If you don't need performance but stability, then Apache.
Nginx is a chicken to deal with dynamic requests. Generally, dynamic requests need to be done by apache, while Nginx is only suitable for static and reverse requests.
4. Configure the version number of the hidden Nginx
Why block Nginx version information?
A: because * * can scan the Nginx version information, you can check the corresponding version information for vulnerabilities, and then do something harmful to the website.
Check the well-known Server name and version number. (all hidden)
4-1, decompress the source package
Tar-xzvf nginx-1.16.0.tar.gz
When cd nginx-1.16.0 enters the directory, you can view the following files
Auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
4-2 vim src/core/nginx.h changes the source code hidden software name and version number
13 # define NGINX_VERSION "1.0.13" can modify the version number independently
14 # define NGINX_VER "WYW/" NGINX_VERSION can modify the software name independently
4-3, modify the connection field in the HTTP header to prevent the specific version number from being echoed
Vim src/http/ngx_http_header_filter_module.c
49 static u_char ngx_http_server_string [] = "Server: WYW" CRLF; can modify the echo service name independently
4-4. Modify the return information of the HTTP error code. Sometimes the error code of the web page will be returned to us, with Nginx and version information.
Vim src/http/ngx_http_special_response.c
36 "WYW" CRLF can modify the service name independently
5 the installation of Jing Nginx officially starts (3 steps and 4 steps can be implemented, depending on your needs.)
5-1, install the required dependency packages first
Yum-y install pcre openssl
5-2, create the specified login user
Useradd-s / sbin/noligin-M nginx-s specifies that logging in to shell-M does not create a home directory
5-3, you can edit directly, execute. / configure, enter and wait for the installation.
If there is an error with the word "C compiler cc is not found" in the installation, the editor is not installed, just execute the following command.
Yum-y install gcc-c++
5-4, edit and add fixed module
/ configure-- prefix=/usr/local/nginx-- user=nginx-- group=nginx-- with-http_ssl_module-- with-http_realip_module-- with-http_gzip_static_module-- with-pcre
-prefix=/usr/local/nginx specifies the installation path
-- user=nginx-- group=nginx specifies users and groups
-- with-http_ssl_module supports ssl encryption
-- with-http_realip_module this module supports displaying the real source IP address, which is mainly used by NGINX as a front-end load balancing server.
-- with-http_gzip_static_module this module specifies compression
-- with-pcre this module supports rewrite function
When you are finished, you can execute echo $? Command, check the return value of the previous command; if it is 0, the previous command is executed correctly; otherwise, if it is not 0, there is an error, check immediately.
5-5, and finally execute the installation command
Make & make install "& &" means "and". Execute the command in front of the symbol, and then execute the command after the symbol.
Echo $? View the return value
Cd / usr/local/nginx/ changes to the home directory
Ls View Files
Conf html logs sbin newly installed Nginx, only these four files
/ usr/local/nginx/sbin/nginx start the service
/ usr/local/nginx/sbin/nginx-s stop is out of service
/ usr/local/nginx/sbin/nginx-s reload restart service
6. Turn off the firewall of the Nginx server and use the host browser to access the Nginx address
Http://192.168.15.129
Prompt Welcome to nginx, the installation experiment is complete
7. Use curl-I to check whether the Nginx service hides the version number.
Curl-I http://192.168.15.129
Successfully see the service name and version number you modified
If you want to test the error return code, it is recommended to use Firefox or 360 browser.
8. Tuning the cache of 8 minutes.
Caching is mainly used for pictures, css,js and other elements with few opportunities to change, especially for pictures, which take up a large bandwidth. We can set pictures to be cached locally in the browser for 30d.
In this way, the user loads slowly the first time, and the second time, it is very fast! When caching, we need to list the extensions that need to be cached!
Expires cache is configured in the server field
Set the web page cache (set the expiration time of static resources, 30 days means 30 days)
Modify the configuration file vim / usr/local/nginx/conf/nginx.conf
Add on line 57
Location ~ *. (ico | gif | bmp | jpg | jpeg | png | swf | js | css | mp3) {
Root html
Expires 30d
}
Check the nginx configuration file: / usr/local/nginx/sbin/nginx-t
Randomly upload a picture to the root of the web page (/ usr/local/nginx/html)
/ usr/local/nginx/sbin/nginx-s reload restart service
Open a browser to test
Http://192.168.15.129/, enter the name of the photo you uploaded.
Press F12 key in the web page (some computers may need to add Fn), find Network, press Ctrl+ R key, display the picture in the page, click the picture to find Header, slide the wheel to find Expires, you can check the local cache time.
The experiment is completed.
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.