狂神说-nginx笔记讲解
参考原⽂
4、配置监听
nginx的配置⽂件是conf⽬录下的f,默认配置的nginx监听的端⼝为80,如果80端⼝被占⽤可以修改为未被占⽤的端⼝即可。
图⽚
当我们修改了nginx的配置⽂件f 时,不需要关闭nginx后重新启动nginx,只需要执⾏命令 nginx -s reload 即可让改动⽣效
5、关闭nginx
如果使⽤cmd命令窗⼝启动nginx, 关闭cmd窗⼝是不能结束nginx进程的,可使⽤两种⽅法关闭nginx
(1)输⼊nginx命令 nginx -s stop(快速停⽌nginx) 或 nginx -s quit(完整有序的停⽌nginx)
(2)使⽤taskkill taskkill /f /t /
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-rad
ius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" class="js_darkmode__25" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. taskkill是⽤来终⽌进程的,
2. /f是强制终⽌ .
3. /t终⽌指定的进程和任何由此启动的⼦进程。
4. /im⽰指定的进程名称 .
</pre>
linux下安装
1、安装gcc
安装 nginx 需要先将官⽹下载的源码进⾏编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" cl
ass="js_darkmode__44" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. yum install gcc-c++
</pre>
2、PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是⼀个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使⽤ pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使⽤ pcre 开发的⼀个⼆次开发库。nginx也需要此库。命令:
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" class="js_darkmode__49" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. yum install -y pcre pcre-devel
</pre>
3、zlib 安装
zlib 库提供了很多种压缩和解压缩的⽅式, nginx 使⽤ zlib 对 http 包的内容进⾏ gzip ,所以需要在 Centos 上安装 zlib 库。
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-rad
ius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" class="js_darkmode__55" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. yum install -y zlib zlib-devel
</pre>
4、OpenSSL 安装
OpenSSL 是⼀个强⼤的安全套接字层密码库,囊括主要的密码算法、常⽤的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应⽤程序供测试或其它⽬的使⽤。
nginx 不仅⽀持 http 协议,还⽀持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" class="js_darkmode__61" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing:
0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. yum install -y openssl openssl-devel
</pre>
5、下载安装包
图⽚
nginx ssl证书配置下载完毕上传到服务器上 /root
6、解压
<pre data-darkmode-bgcolor-16206563839693="rgb(34, 34, 34)" data-darkmode-original-bgcolor-
16206563839693="#fff|rgb(246, 246, 246)" data-darkmode-color-16206563839693="rgb(186, 193, 199)" data-darkmode-original-color-16206563839693="#fff|rgb(33, 37, 41)" data-YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow: auto; color: rgb(33, 37, 41); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border-width: 1px; border-style: solid; border-color: rgb(221, 221, 221); text-align: left;" class="js_darkmode__68" YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; letter-
spacing: 0.544px; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; list-style: none; overflow: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap;
border-radius: 3px; border-width: 1px; border-style: solid; text-align: left;">
1. tar -zxvf nginx-1.18.
2. cd nginx-1.18.0
</pre>
图⽚
7、配置
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论