软件使用情况排行榜:
![](https://img2022.cnblogs.com/blog/2861620/202206/2861620-20220605202318654-1347212015.png)
优点
缺点
特点
Nginx "偶数"为稳定版
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
centos8中
yum info nginx //查看旧版本
cat > /etc/yum.repos.d/nginx.repo
#
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
#
yum list nginx //更新Nginx版本
yum install nginx
rpm -ql nginx //查看Nginx文件 核心文件:/etc/nginx/nginx_conf
systemctl enable --now nginx //启动Nginx软件
ss -ntlp //查看端口
pstree -p //查看进程树,可以发现没有"线程"
nginx -V // 查看Nginx的版本
3. yum官方源安装
cat /etc/yum.repos.d/nginx.repo
dnf info nginx //查看版本信息
yum -y install nginx //安装nginx
https://nginx.org/en/download.html
yum -y install gcc pcre-devel openssl-devel zlib-devel
useradd -s /sbin/nologin nginx //创建Nginx专有用户
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar xf nginx-1.18.0.tar.gz
wget https://nginx.org/download/nginx-1.20.2.tar.gz
tar xf nginx-1.20.2.tar.gz
cd nginx-1.20.2/
cd nginx-1.18.0/
#直接复制一下代码
./configure --prefix=/apps/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
make && make install
chown -R nginx.nginx /apps/nginx //修改权限
、
find src -type f | xargs cat |wc -l //统计源码行数
cat /apps/nginx/run/nginx.pid //查看端口
ps auxf|grep nginx //
kill -USR2 `cat /apps/nginx/run/nginx.pid //平滑升级
ps auxf|grep nginx //查看nginx
lsof -i :80 //查看监听端口
kill -QUIT `cat/apps/nginx/run/nginx.pid.oldbin` //优雅关闭
ps aux | grep nginx //查看Nginx 的进程
1.启动Nginx 的核心数量 = cpu颗粒数(减少cpu工作进程不同的来回跳转,减少cpu的资源分配和内存管理)
ps aux pid,cmd,psr | grep nginx //查看cpu和Nginx是否一致
2.cpu和Nginx worker的进程一一静态绑定
accept_mutex on
multi_accept on
vim /apps/nginx/conf/nginx.conf
添加配置内容如下:
accept_mutex on
multi_accept on
本文来自博客园,作者:林清|Julien,转载请注明原文链接:https://www.cnblogs.com/Julien1021/p/16344843.html