Table of contents
1, 2 Advantages of Nginx over Apache
1.3 Nginx application scenarios
2. Compile and install nginx service
Three, nginx smooth upgrade (update)
1. nginx service foundation
1.1 Introduction to Nginx
Nginx ("engine x") is a high-performance HTTP and reverse proxy server. Nginx was developed by Igor Sysoev for Rambler.ru, the second largest access point in Russia. The first public version 0.1.0 was released on October 4, 2004. It releases its source code under a BSD-like license and is known for its stability, rich feature set, sample configuration files, and low consumption of system resources. On June 1, 2011, Nginx 1.0.4 was released. 1.18 1.20 1.22 1.12
Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server. A single physical server can support 30,000 to 50,000 concurrent requests. And released under a BSD-like license. Developed by Russian programmer Igor Sysoev, it is used by Russia's large portal and search engine Rambler (Russian: Рамблер). It is characterized by less memory and strong concurrency capability. In fact, the concurrency capability of Nginx is indeed better than that of the same type of web servers. The users of Nginx websites in mainland China include: Baidu BWS, Sina, Netease, Tencent, etc.
1, 2 Advantages of Nginx over Apache
Nginx is a web server rather than events, Apache is a process-based server;
Nginx avoids the concept of subprocesses, Apache is based on subprocesses;
Nginx is better in terms of memory consumption and connections, Apache is average in terms of memory consumption and connections
The performance and scalability of Nginx do not depend on hardware, while Apache depends on hardware such as CPU and memory;.
Nginx supports hot deployment, Apache does not support hot deployment;
Nginx is more efficient for static file processing, Apache is relatively general;
Nginx has obvious advantages in reverse proxy scenarios, while Apache is relatively general.
1.3 Nginx application scenarios
①Static server (picture, video service, text)
②Dynamic service
③Reverse proxy, load balancing
④Cache service
2. Compile and install nginx service
1. Download the compressed package from the official website
Nginx Chinese reference address: Nginx Chinese Documentation
2. Turn off the firewall
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
3. Install dependent packages
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
4. Start compiling and installing
cd /opt
tar zxvf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.12.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make && make install
5. Make nginx soft links to let the system recognize nginx operation commands
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
Three, nginx smooth upgrade (update)
1. Unzip the upgrade package
2. Compile and install
cd nginx-1.xx.xx
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module
make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_old backup
cp objs/nginx /usr/local/nginx/sbin/nginx
restart service and
nginx -V