In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to deploy nginx optimization, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Nginx was designed and developed by lgor Sysoev for the second most visited rambler.ru site in Russia. Since its release in 2004, with the power of open source, it has been close to maturity and perfection.
Nginx has rich functions and can be used as a HTTP server, a reverse proxy server and a mail server. Support FastCGI, SSL, Virtual Host, URL Rewrite, Gzip and other functions. And support many third-party module extensions.
Nginx's stability, feature set, sample profile and low consumption of system resources make him come from behind, with a usage rate of 12.18% of the world's active websites, about 22.2 million sites.
To study how to install and clean nginx repeatedly during nginx optimization, a simple deployment script is made, which uses the latest stable version 1.14.0, the default path, and joins the process management of systemd system. You can manage nginx startup, termination, reload, status, boot self-startup and so on through systemd.
#! / bin/bashyum-y install gcc pcre pcre-develsleep 2cd ~ tar-zxvf ~ / zlib-1.2.11.tar.gzcd ~ / zlib-1.2.11 & &. / configure & & make & & make installcd ~ tar-zxvf ~ / nginx-1.14.0.tar.gzcd ~ / nginx-1.14.0 & &. / configure & & make & & make installcd ~ # / usr/local/nginx/sbin/nginxfirewall-cmd-set-default-zone=trustedtouch / lib/systemd/system/ Nginx.serviceecho "[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx reloadExecStop=/usr/local/nginx/sbin/nginx quitPrivateTmp=true [Install] WantedBy=multi-user.target" > / lib/systemd/system/nginx.servicesystemctl enable nginx.servicesystemctl restart nginx.serviceecho "nginx done"
When you need to overwrite nginx again, use awk to find the nginx process, then kill it, and execute the installation script again.
Kill-9 $`ps aux | grep 'nginx' | awk' NR==2 {print $2}'`
II. Nginx optimization
The nginx optimization configuration focuses on the main and events segments of the nginx.conf file.
In the worker configuration in the main section, you can use the work_cpu_affinity option to bind each worker process running on which CPU core according to the actual business situation by task type: CPU-intensive or IO-intensive (provided that the system must be a multi-core CPU), for example
# 4 in the core CPU, 4 worker are enabled, and each worker corresponds to cpu0/cpu1/cpu2/cpu. Worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000; in # 4 core CPU, only 2 worker can be enabled. The first worker corresponds to cpu0/cpu2 and the second worker corresponds to cpu1/cpu3. Worker_processes 2; worker_cpu_affinity 0101 1010
Enable centralized one-time access connection request and serial access to new connection in envents segment
Events {worker_connections 1024; # maximum number of connections per worker. Whether multi_accept on; # centralizes access to monitored connection requests. Default is off. When closed, only one connection is received at a time. Accept_mutex on # defaults to on, which means that the new connection is accessed in a serial manner. When off, all worker will be notified.
Others, such as HTTP segment optimization, sendfile, keepalive_timeout, gzip are required in nginx.
Thank you for reading this article carefully. I hope the article "how to deploy and optimize nginx" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.