Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好。
一、安装启动
1.1、查看系统nginx版本
dnf module list nginx
[root@bogon ~]$ dnf module list nginx
上次元数据过期检查:1:51:09 前,执行于 2023年02月23日 星期四 15时25分30秒。
Loongnix server 8.4 - AppStream
Name Stream Profiles Summary
nginx 1.14 [d] common [d] nginx webserver
nginx 1.16 common [d] nginx webserver
提示:[d]默认,[e]已启用,[x]已禁用,[i]已安装
1.2、nginx软件包安装
dnf module install nginx:1.16
1.3、启动nginx服务
systemctl start nginx.service
systemctl status nginx.service
二、测试
2.1、通过浏览器界面进行验证
2.2、通过curl打印首页信息
[root@bogon ~]$ curl -I 10.130.0.73
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Thu, 23 Feb 2023 09:34:16 GMT
Content-Type: text/html
Content-Length: 3952
Last-Modified: Mon, 01 Nov 2021 08:49:34 GMT
Connection: keep-alive
ETag: "617faa1e-f70"
Accept-Ranges: bytes
2.3、Apache Benchmark 压力工具测试
安装ab测试工具包
yum install httpd-tools
-n 指定总访问量,-c 指定并发访问量
ab -n 500000 -c 500 http://localhost:80/
[root@bogon ~]$ ab -n 500000 -c 500 http://localhost:80/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 50000 requests
Completed 100000 requests
Completed 150000 requests
Completed 200000 requests
Completed 250000 requests
Completed 300000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 311300 requests complete