简介是一个高性能的 HTTP 和反向代理服务器 , 特点是占有内存少 , 并发能力强 , 事实上 nginx 的并发能力确实在同类型的网页服务器中表现较好 。
Nginx 可以作为静态页面的 web 服务器 , 同时还支持 CGI 协议的动态语言 , 比如 perl、php 等 。但是不支持 Java 。Java 程序只能通过与 tomcat 配合完成 。Nginx 专为性能优化而开发 , 性能是其最重要的考量,实现上非常注重效率 , 能经受高负载的考验 , 有报告表明能支持高达 50,000 个并发连接数 。
安装安装编译工具及库文件yum -y install make zlib zlib-devel gcc-c++ libtoolopenssl openssl-devel在下载的过程中提示 正 在 尝 试 其 它 镜 像 的话 , 就继续等待吧 , 总会有成功的一次 。
安装 PCREPCRE 作用是让 Nginx 支持 Rewrite 功能 。
下载 PCRE 安装包 , 下载地址:https://nchc.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
网盘下载地址
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz-rw-r--r--.1 root root2096552 6月22 2021 pcre-8.45.tar.gz解压安装包
[root@localhost src]# tar zxvf pcre-8.45.tar.gz进入安装包目录编译安装
[root@localhost src]# cd pcre-8.45[root@localhost pcre-8.45]# ./configure[root@localhost pcre-8.45]# make && make install查看 pcre 版本
[root@localhost pcre-8.45]# pcre-config --version8.45安装 Nginx下载地址:https://nginx.org/download/nginx-1.21.6.tar.gz
[root@localhost local]# wget https://nginx.org/download/nginx-1.21.6.tar.gz解压安装包
[root@localhost local]# tar zxvf nginx-1.21.6.tar.gz 编译安装
[root@localhost local]# cd nginx-1.21.6[root@localhost nginx-1.21.6]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/src/pcre-8.45[root@localhost nginx-1.21.6]# make[root@localhost nginx-1.21.6]# make install查看 Nginx 版本
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -vnginx version: nginx/1.21.6常用命令启动 Nginx[root@localhost /]# /usr/local/nginx/sbin/nginx检查配置文件的准确性[root@localhost nginx]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful重新载入配置文件[root@localhost nginx]# /usr/local/nginx/sbin/nginx -s reload重启 Nginx[root@localhost nginx]# /usr/local/nginx/sbin/nginx -s reopen停止 Nginx[root@localhost nginx]# /usr/local/nginx/sbin/nginx -s stop配置文件解读#usernobody;# 这是 Nginx 服务器并发处理服务的关键配置 , worker_processes 值越大 , 可以支持的并发处理量也越多 , 但是会受到硬件、软件等设备的制约worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;# events 涉及的指令主要影响 Nginx 服务器与用户的网络连接events { # 支持的最大连接数是多少worker_connections1024;}# 包含 http 全局块和 server 块http {includemime.types;default_typeapplication/octet-stream;sendfileon;#tcp_nopushon;#keepalive_timeout0;keepalive_timeout65;#gzipon;server {# 监听的端口号listen80;# 主机名称server_namelocalhost;location / {roothtml;indexindex.html index.htm;}# redirect server error pages to the static page /50x.html#error_page500 502 503 504/50x.html;location = /50x.html {roothtml;}}}配置文件正则表达式location [ = | ~ | ~* | ^~ ] uri {}
- = :用于不含正则表达式的 uri 前 , 要求请求字符串与 uri 严格匹配 , 如果匹配 成功 , 就停止继续向下搜索并立即处理该请求 。
- ~ :用于表示 uri 包含正则表达式 , 并且区分大小写 。
- ~* :用于表示 uri 包含正则表达式 , 并且不区分大小写 。
- ^~ :用于不含正则表达式的 uri 前 , 要求 Nginx 服务器找到标识 uri 和请求字 符串匹配度最高的 location 后 , 立即使用此 location 处理请求 , 而不再使用 location块中的正则 uri 和请求字符串做匹配 。
- 春季老年人吃什么养肝?土豆、米饭换着吃
- 三八妇女节节日祝福分享 三八妇女节节日语录
- 老人谨慎!选好你的“第三只脚”
- 校方进行了深刻的反思 青岛一大学生坠亡校方整改校规
- 脸皮厚的人长寿!有这特征的老人最长寿
- 长寿秘诀:记住这10大妙招 100%增寿
- 春季老年人心血管病高发 3条保命要诀
- 眼睛花不花要看四十八 老年人怎样延缓老花眼
- 香槟然能防治老年痴呆症? 一天三杯它人到90不痴呆
- 老人手抖的原因 为什么老人手会抖
