In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to upgrade nginx to support http2, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
One-click upgrade script
Https://github.com/whisshe/upHttp2.git
Advantages of HTTP/2
Compared with HTTP/1.x,HTTP/2 in the underlying transmission has made a lot of changes and optimization:
HTTP/2 transmits data in binary format instead of HTTP/1.x text format. Binary format brings more advantages and possibilities in protocol parsing and optimization expansion.
HTTP/2 uses HPACK to compress and transmit the message header, which can save the network traffic occupied by the message header. However, every time HTTP/1.x requests, it will carry a lot of redundant header information, which wastes a lot of bandwidth resources. Head compression can solve this problem very well.
Multiplexing, to put it bluntly, is that all requests are done concurrently through a TCP connection. Although HTTP/1.x can also make concurrent requests through pipeline, the response between multiple requests will be blocked, so pipeline has not been widely used so far, and HTTP/2 has achieved real concurrent requests. At the same time, the flow also supports priority and flow control.
Server Push: the server can push resources to the client more quickly. For example, the server can actively push JS and CSS files to the client without requiring the client to parse the HTML and then send these requests. When the client needs it, it is already on the client side.
Necessary conditions for upgrading HTTP2
Nginx versions 1.10.0 and above are compiled based on openssl versions 1.0.2 and above
Https must be supported
Software installation location
Openssl
1. Compilation location
/ usr/local/openssl
2. Soft link location
/ usr/bin/openssl
/ usr/include/openssl
Nginx
1. Compilation and configuration file location
/ etc/nginx
Upgrade the nginx and OpenSSL of all game servers
Upgrade openssl
1. Back up the old version of openssl
Mv / usr/bin/openssl / usr/bin/openssl.oldmv / usr/include/openssl / usr/include/openssl.old
2. Download version 1.1 of openssl and decompress the compiler.
Wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz tar zxvf openssl-1.1.0g.tar.gz cd openssl-1.1.0g/. / config-- prefix=/usr/local/openssl shared zlib make depend make & & make install ln-s / usr/local/openssl/bin/openssl / usr/bin/openssl ln-s / usr/local/openssl/include/openssl / usr/include/openssl (preferred) cd / usr/local/openssl/lib ln -s libssl.so.1.1 libcrypto.so.1.1 / lib/x86_64-linux-gnu/ echo / usr/local/openssl/lib > > / etc/ld.so.conf
3. Verify openssl version information
Openssl versionif [[`openssl version | awk'{print $2}'`= 1.1.0g]; then echo okfi
Nginx upgrade (source code compilation)
The original configuration file will not be lost
1. Download the source package
Wget http://nginx.org/download/nginx-1.12.2.tar.gz
2. Decompress, compile and install
When compiling and installing nginx, the-- with-openssl parameter only supports the source code of OpenSSL by default, not the compiled OpenSSL. You can modify auto/lib/openssl/conf in the decompressed directory of nginx
Sed "s/.openssl\ / /" c
Remove the .openssl from the file and support the compiled openssl path.
CORE_INCS= "$CORE_INCS $OPENSSL/.openssl/include" CORE_DEPS= "$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" CORE_LIBS= "$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" CORE_LIBS= "$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
Formal compilation
. / configure-- prefix=/etc/nginx\-- sbin-path=/usr/sbin/nginx\-- conf-path=/etc/nginx/nginx.conf\-- error-log-path=/var/log/nginx/error.log\-- http-log-path=/var/log/nginx/access.log\-- pid-path=/var/run/nginx.pid\-- lock-path=/var/run/nginx.lock\-- http-client-body-temp-path=/ Var/cache/nginx/client_temp\-http-proxy-temp-path=/var/cache/nginx/proxy_temp\-http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp\-http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp\-http-scgi-temp-path=/var/cache/nginx/scgi_temp\-with-http_ssl_module\-with-http_realip_module\-with -http_addition_module\-- with-http_sub_module\-- with-http_dav_module\-- with-http_flv_module\-- with-http_mp4_module\-with-http_gunzip_module\-- with-http_gzip_static_module\-- with-http_random_index_module\-- with-http_secure_link_module\-- with-http_stub_status_module\-- with-http _ auth_request_module\-with-threads\-- with-stream\-- with-stream_ssl_module\-- with-http_slice_module\-- with-mail\-- with-mail_ssl_module\-- with-file-aio\-- with-http_v2_module\-- with-openssl=/usr/local/openssl
Modify nginx configuration
Listen 443 ssl http2
Problems and solutions
Openssl version reports error openssl: error while loading shared libraries: libssl.so.1.1 under centos7
Echo / usr/local/openssl/lib > > / etc/ld.so.conf # add the lib library of the openssl compilation path to / etc/ld.so.confldconfig-v | grep libssl # check whether the addition is successful
Error occurred in nginx restart. Nginx: [emerg] mkdir () "/ var/cache/nginx/client_temp" failed
Ls-l / var/cache/nginx/client_temp# checks whether the folder exists and the permissions of the folder mkdir-p / var/cache/nginx/client_temp# folder does not exist, then generate the folder chown-R www-data:www-data / var/cache/nginx/client_temp# to change the folder owner and group to the running user of nginx. For more information, see nginx.conf above is all the content of the article "how to upgrade nginx to support http2" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.