Nginx入门到实践---nginx中间件
第1章 课程前言
1-1 课程介绍 (12:45)
高效:体现在海量的并发请求上
可靠:体现在这软件上是可靠的
开源:
本课程讲解内容:
本文的目的:
1-2 学习环境准备 (07:36)
1:确认系统网络:即:可以访问外网。
3: 确认yum 可用:
View CodeCentos7 防火墙关闭和启用iptables防火墙 操作系统环境:CentOS Linux release 7.0.1406(Core) 64位 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。 1、关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running) 2、iptables防火墙(这里iptables已经安装,下面进行配置) vi/etc/sysconfig/iptables #编辑防火墙配置文件 # sampleconfiguration for iptables service # you can edit thismanually or use system-config-firewall # please do not askus to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT[0:0] :OUTPUT ACCEPT[0:0] -A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -jACCEPT -A INPUT -i lo -jACCEPT -A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT -A INPUT -j REJECT--reject-with icmp-host-prohibited -A FORWARD -jREJECT --reject-with icmp-host-prohibited COMMIT :wq! #保存退出 备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。 systemctlrestart iptables.service #最后重启防火墙使配置生效 systemctlenable iptables.service #设置防火墙开机启动 -----如果没有安装iptable防火墙 官方文档介绍地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html#sec-Introduction_to_firewalld1 一、firewall介绍 CentOS 7中防火墙是一个非常的强大的功能,在CentOS 6.5中在iptables防火墙中进行了升级了。 1、官方介绍 The dynamic firewall daemon firewalld provides a dynamically managed firewall with support for network “zones” to assign a level of trust to a network and its associated connections and interfaces. It has support for IPv4 and IPv6 firewall settings. It supports Ethernet bridges and has a separation of runtime and permanent configuration options. It also has an interface for services or applications to add firewall rules directly. 2、什么是区域Zone: 网络区域定义了网络连接的可信等级。这是一个 一对多的关系,这意味着一次连接可以仅仅是一个区域的一部分,而一个区域可以用于很多连接。 3、哪个区域可用? 由firewalld 提供的区域按照从不信任到信任的顺序排序。 4、区域的分类? Firewalls can be used to separate networks into different zones based on the level of trust the user has decided to place on the devices and traffic within that network. NetworkManager informs firewalld to which zone an interface belongs. An interface’s assigned zone can be changed by NetworkManager or via the firewall-config tool which can open the relevant NetworkManager window for you. The zone settings in /etc/firewalld/ are a range of preset settings which can be quickly applied to a network interface. They are listed here with a brief explanation: drop Any incoming network packets are dropped, there is no reply. Only outgoing network connections are possible. block Any incoming network connections are rejected with an icmp-host-prohibited message for IPv4 and icmp6-adm-prohibited for IPv6. Only network connections initiated from within the system are possible. public For use in public areas. You do not trust the other computers on the network to not harm your computer. Only selected incoming connections are accepted. external For use on external networks with masquerading enabled especially for routers. You do not trust the other computers on the network to not harm your computer. Only selected incoming connections are accepted. dmz For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted. work For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted. home For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted. internal For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted. trusted All network connections are accepted. It is possible to designate one of these zones to be the default zone. When interface connections are added to NetworkManager, they are assigned to the default zone. On installation, the default zone in firewalld is set to be the public zone. 注:具体内容,请参见官方文档介绍! 二、firewall配置 The configuration for firewalld is stored in various XML files in /usr/lib/firewalld/ and /etc/firewalld/. This allows a great deal of flexibility as the files can be edited, written to, backed up, used as templates for other installations and so on. 注意:以下firewalld 的操作只有重启之后才有效:service firewalld restart 重启 1、系统配置目录 /usr/lib/firewalld/services 目录中存放定义好的网络服务和端口参数,系统参数,不能修改。 这里写图片描述 2、用户配置目录 /etc/firewalld/ 3、如何自定义添加端口 用户可以通过修改配置文件的方式添加端口,也可以通过命令的方式添加端口,注意,修改的内容会在/etc/firewalld/ 目录下的配置文件中还体现。 3.1、命令的方式添加端口 firwall-cmd --permanent --add-port=9527/tcp 参数介绍: 1、firwall-cmd:是Linux提供的操作firewall的一个工具; 2、--permanent:表示设置为持久; 3、--add-port:标识添加的端口; 另外,firewall中有Zone的概念,可以将具体的端口制定到具体的zone配置文件中。 例如:添加8010端口 firewall-cmd --zone=public --permanent --add-port=8010/tcp --zone=public:指定的zone为public; 添加结果如下: 这里写图片描述 如果–zone=dmz 这样设置的话,会在dmz.xml文件中新增一条。 3.2、修改配置文件的方式添加端口 复制代码 <?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description>For use in public areas.</description> <rule family="ipv4"> <source address="122.10.70.234"/> <port protocol="udp" port="514"/> <accept/> </rule> <rule family="ipv4"> <source address="123.60.255.14"/> <port protocol="tcp" port="10050-10051"/> <accept/> </rule> <rule family="ipv4"> <source address="192.249.87.114"/> 放通指定ip,指定端口、协议 <port protocol="tcp" port="80"/> <accept/> </rule> <rule family="ipv4"> 放通任意ip访问服务器的9527端口 <port protocol="tcp" port="9527"/> <accept/> </rule> </zone> 复制代码 上述的一个配置文件可以很好的看出: 1、添加需要的规则,开放通源ip为122.10.70.234,端口514,协议tcp; 2、开放通源ip为123.60.255.14,端口10050-10051,协议tcp;/3、开放通源ip为任意,端口9527,协议tcp; 三、firewall常用命令 1、重启、关闭、开启firewalld.service服务 service firewalld restart 重启 service firewalld start 开启 service firewalld stop 关闭 2、查看firewall服务状态 systemctl status firewall 3、查看firewall的状态 firewall-cmd --state 这里写图片描述 4、查看防火墙规则 firewall-cmd --list-all 这里写图片描述 四、CentOS切换为iptables防火墙 切换到iptables首先应该关掉默认的firewalld,然后安装iptables服务。 1、关闭firewall: service firewalld stop systemctl disable firewalld.service #禁止firewall开机启动 2、安装iptables防火墙 yum install iptables-services #安装 3、编辑iptables防火墙配置 vi /etc/sysconfig/iptables #编辑防火墙配置文件 下边是一个完整的配置文件: 复制代码 Firewall configuration written by system-config-firewall Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT 复制代码 :wq! #保存退出 service iptables start #开启 systemctl enable iptables.service #设置防火墙开机启动
View CodeCentOS7关闭SELINUX 安全增强型Linux(Security-Enhanced Linux)简称SELinux,它是一个 Linux 内核模块,也是Linux的一个安全子系统。为了避免安装过程出现各种错误,建议关闭,有如下两种关闭方法: 1)临时关闭(不建议使用) [root@hadoop101 ~]# setenforce 0 但是这种方式只对当次启动有效,重启机器后会失效。 2)永久关闭(建议使用) 修改配置文件/etc/selinux/config [root@hadoop101 ~]# vim /etc/selinux/config 将SELINUX=enforcing 改为SELINUX=disabled 复制代码 # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted 复制代码 3)同步/etc/selinux/config配置文件(这一步是针对集群环境中,参考:使用集群同步脚本对配置文件同步分发) [root@hadoop101 ~]# xsync /etc/selinux/config 4)重启主机 [root@hadoop101 ~]# reboot [root@hadoop102 ~]# reboot [root@hadoop103 ~]# reboot 分类: Linux
app:代码目录
download: 下载下来的 代码包 等类似的文件
logs: 自定义日志
work:需要执行的脚本
backup:存放默认的配置文件,及一些日常的备份文件
[root@localhost backups]# ping www.baidu.com PING www.baidu.com (14.215.177.38) 56(84) bytes of data. 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=55 time=8.47 ms 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=55 time=8.72 ms 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=55 time=8.59 ms ^C --- www.baidu.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 8.470/8.597/8.729/0.150 ms [root@localhost backups]# yum list | grep gcc devtoolset-9-gcc.x86_64 9.3.1-2.el7 @centos-sclo-rh devtoolset-9-gcc-c++.x86_64 9.3.1-2.el7 @centos-sclo-rh gcc.x86_64 4.8.5-44.el7 @anaconda gcc-c++.x86_64 4.8.5-44.el7 @anaconda gcc-gfortran.x86_64 4.8.5-44.el7 @anaconda libgcc.x86_64 4.8.5-44.el7 @anaconda compat-gcc-44.x86_64 4.4.7-8.el7 base compat-gcc-44-c++.x86_64 4.4.7-8.el7 base compat-gcc-44-gfortran.x86_64 4.4.7-8.el7 base devtoolset-10-gcc.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-gcc-c++.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-gcc-gdb-plugin.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-gcc-gfortran.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-gcc-plugin-devel.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-libgccjit.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-libgccjit-devel.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-10-libgccjit-docs.x86_64 10.2.1-11.1.el7 centos-sclo-rh devtoolset-7-gcc.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-gcc-c++.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-gcc-gdb-plugin.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-gcc-gfortran.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-gcc-plugin-devel.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-libgccjit.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-libgccjit-devel.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-7-libgccjit-docs.x86_64 7.3.1-5.16.el7 centos-sclo-rh devtoolset-8-gcc.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-gcc-c++.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-gcc-gdb-plugin.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-gcc-gfortran.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-gcc-plugin-devel.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-libgccjit.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-libgccjit-devel.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-8-libgccjit-docs.x86_64 8.3.1-3.2.el7 centos-sclo-rh devtoolset-9-gcc.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-gcc-c++.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-gcc-gdb-plugin.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-gcc-gfortran.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-gcc-plugin-devel.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-libgccjit.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-libgccjit-devel.x86_64 9.3.1-2.2.el7 centos-sclo-rh devtoolset-9-libgccjit-docs.x86_64 9.3.1-2.2.el7 centos-sclo-rh gcc-gnat.x86_64 4.8.5-44.el7 base gcc-go.x86_64 4.8.5-44.el7 base gcc-objc.x86_64 4.8.5-44.el7 base gcc-objc++.x86_64 4.8.5-44.el7 base gcc-plugin-devel.x86_64 4.8.5-44.el7 base libgcc.i686 4.8.5-44.el7 base relaxngcc.noarch 1.12-6.el7 base relaxngcc-javadoc.noarch 1.12-6.el7 base [root@localhost backups]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@localhost backups]# iptables -F [root@localhost backups]# iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination [root@localhost backups]# iptables -t nat -F [root@localhost backups]# getenforce Enforcing [root@localhost backups]# setenforce usage: setenforce [ Enforcing | Permissive | 1 | 0 ] [root@localhost backups]# setenforce 0 [root@localhost backups]# getenforce Permissive [root@localhost backups]#
调试环境:
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
[root@localhost backups]# yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: ftp.sjtu.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Package gcc-4.8.5-44.el7.x86_64 already installed and latest version Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version Package autoconf-2.69-11.el7.noarch already installed and latest version Package pcre-8.32-17.el7.x86_64 already installed and latest version Package 1:make-3.82-24.el7.x86_64 already installed and latest version Package automake-1.13.4-3.el7.noarch already installed and latest version Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================= Package Arch Version Repository Size ========================================================================================= Installing: pcre-devel x86_64 8.32-17.el7 base 480 k Transaction Summary ========================================================================================= Install 1 Package Total download size: 480 k Installed size: 1.4 M Downloading packages: pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pcre-devel-8.32-17.el7.x86_64 1/1 Verifying : pcre-devel-8.32-17.el7.x86_64 1/1 Installed: pcre-devel.x86_64 0:8.32-17.el7 Complete! [root@localhost backups]#
yum -y install wget httpd-tools vim
[root@localhost backups]# yum -y install wget httpd-tools vim Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: ftp.sjtu.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Package wget-1.14-18.el7_6.1.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package httpd-tools.x86_64 0:2.4.6-95.el7.centos will be updated --> Processing Dependency: httpd-tools = 2.4.6-95.el7.centos for package: httpd-2.4.6-95.el7.centos.x86_64 ---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos.1 will be an update ---> Package vim-enhanced.x86_64 2:7.4.629-7.el7 will be updated ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be an update --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64 --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-95.el7.centos will be updated --> Processing Dependency: httpd = 2.4.6-95.el7.centos for package: mod_session-2.4.6-95.el7.centos.x86_64 ---> Package httpd.x86_64 0:2.4.6-97.el7.centos.1 will be an update ---> Package vim-common.x86_64 2:7.4.629-7.el7 will be updated ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be an update --> Running transaction check ---> Package mod_session.x86_64 0:2.4.6-95.el7.centos will be updated ---> Package mod_session.x86_64 0:2.4.6-97.el7.centos.1 will be an update --> Finished Dependency Resolution Dependencies Resolved ========================================================================================= Package Arch Version Repository Size ========================================================================================= Updating: httpd-tools x86_64 2.4.6-97.el7.centos.1 updates 93 k vim-enhanced x86_64 2:7.4.629-8.el7_9 updates 1.1 M Updating for dependencies: httpd x86_64 2.4.6-97.el7.centos.1 updates 2.7 M mod_session x86_64 2.4.6-97.el7.centos.1 updates 63 k vim-common x86_64 2:7.4.629-8.el7_9 updates 5.9 M Transaction Summary ========================================================================================= Upgrade 2 Packages (+3 Dependent packages) Total size: 9.8 M Total download size: 2.9 M Downloading packages: No Presto metadata available for updates (1/3): httpd-tools-2.4.6-97.el7.centos.1.x86_64.rpm | 93 kB 00:00:00 (2/3): mod_session-2.4.6-97.el7.centos.1.x86_64.rpm | 63 kB 00:00:00 (3/3): httpd-2.4.6-97.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:01 ----------------------------------------------------------------------------------------- Total 1.7 MB/s | 2.9 MB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : httpd-tools-2.4.6-97.el7.centos.1.x86_64 1/10 Updating : httpd-2.4.6-97.el7.centos.1.x86_64 2/10 Updating : 2:vim-common-7.4.629-8.el7_9.x86_64 3/10 Updating : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 4/10 Updating : mod_session-2.4.6-97.el7.centos.1.x86_64 5/10 Cleanup : mod_session-2.4.6-95.el7.centos.x86_64 6/10 Cleanup : httpd-2.4.6-95.el7.centos.x86_64 7/10 Cleanup : 2:vim-enhanced-7.4.629-7.el7.x86_64 8/10 Cleanup : httpd-tools-2.4.6-95.el7.centos.x86_64 9/10 Cleanup : 2:vim-common-7.4.629-7.el7.x86_64 10/10 Verifying : 2:vim-common-7.4.629-8.el7_9.x86_64 1/10 Verifying : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 2/10 Verifying : httpd-tools-2.4.6-97.el7.centos.1.x86_64 3/10 Verifying : mod_session-2.4.6-97.el7.centos.1.x86_64 4/10 Verifying : httpd-2.4.6-97.el7.centos.1.x86_64 5/10 Verifying : 2:vim-common-7.4.629-7.el7.x86_64 6/10 Verifying : mod_session-2.4.6-95.el7.centos.x86_64 7/10 Verifying : httpd-tools-2.4.6-95.el7.centos.x86_64 8/10 Verifying : httpd-2.4.6-95.el7.centos.x86_64 9/10 Verifying : 2:vim-enhanced-7.4.629-7.el7.x86_64 10/10 Updated: httpd-tools.x86_64 0:2.4.6-97.el7.centos.1 vim-enhanced.x86_64 2:7.4.629-8.el7_9 Dependency Updated: httpd.x86_64 0:2.4.6-97.el7.centos.1 mod_session.x86_64 0:2.4.6-97.el7.centos.1 vim-common.x86_64 2:7.4.629-8.el7_9 Complete! [root@localhost backups]#
安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
初始化文件目录:
cd /opt;mkdir app download logs work backup
[root@localhost ~]# ls anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Desktop Downloads Music Public Videos [root@localhost ~]# cd /opt [root@localhost opt]# ls rh [root@localhost opt]# cd /opt;mkdir app download logs work backup [root@localhost opt]# ls app backup download logs rh work [root@localhost opt]#
app:代码目录
download: 下载下来的 代码包 等类似的文件
logs: 自定义日志
work:需要执行的脚本
backup:存放默认的配置文件,及一些日常的备份文件
第2章 基础篇 34 节 | 201分钟
讲解Nginx的快速部署安装、模块、基础配置语法。Nginx的日志输出、Nginx默认配置模块。Nginx对于请求的处理,访问控制模块使用,并区别介绍连接限制与请求限制。
2-1 什么是Nginx (03:24)
1:什么是中间件
首先我们进入到的是基础篇,在纪录片我们先来介绍给大家的是什么是中间件。 在我们的网站后台往往存在有很多的应用服务,对应的是在我们的操作系统来驱动我们的硬件,为我们提供对应的服务。 那么应用与应用之间的直接调用,或者应用直接与操作系统的交互,这样的话会导致一个什么样的问题? 我们在很多的应用的情况下层次化的应用不够隔离,代码偶合程度高,我们需要有一个东西能够为我们来代理、来处理对应的一些请求,不让应用只负责业务的逻辑处理,这样的话就出现了一个中间件,那么中间件它可以起到与操作系统直接的调用,也可以调用应用分发给对应的应用去进行相应的逻辑寻求,这样的话整个网站承上启下、层次性的作用就会越发的好。 那么中间件可以直接对你接受web请求,并把请求直接给操作系统,返回给这个请求。 当然对于有逻辑性的请求,请求给应用a,中间件也可以起到一个代理和分发的作用。 那么对于应用a同样再去操作我们的操作系统。 那么另外一个更多的场景里边,我们的应用往往不是独立去进行请求处理的,往往需要依赖别的应用来为我们进行处理。 这个时候应用a同样可以去进行中间件,先请求对应的中间件,然后让中间件去分发给对应的应用,这样的话在大型的网站之中有了一个一个的中间件的串联,使得我们的网站层次性更高,维护起来也会非常简。
那么对于现在中间件的地位是越来越高,我们不仅可以用来做这一些,往往可以实现的是对于web请求的,比如说请求的负载均衡,比如说对于http请求的缓存服务,然后也可以实现对于安全、应用、防控等等设置,这个的话就是中间件的一个作用。
那么nginx是什么?
既然我们说了中间件,那么index就是一个开源、高性能、可靠的http中间件的代理服务,那么开源表示它的源代码是开放的,我们可以从它的官方网站里面直接获取到nginx。
源代码,并且可以进行二次的开发。
2-2 常见的中间件服务 (01:53)
那么我们已经讲了nginx是http的中间件的服务,也可以作为http的代理的。 那么我们来讲一讲跟engine类似的还有哪一些服务在市场上有些占有率比较高。 诶这一侧呢我列了三个,一个是http,一个是iis http, 阿帕奇基金会的产品,iis呢是微软,也就是mac source的脉络中间件服务产品。 那么gws是google,那么它的全称呢是google web server,这个呢它是不对外开放的,也就是我们对google的这个外部服务呢了解的不会特别多,据说它的性能呢会也是非常的优越的。
那么http。 和iis在早五、六年前,甚至在更早的时候,应该是在这个图上面,通过这个map的这个图来我看的话应该是在一七年、一八年之前,这两个服务呢在市场的占有率呢都是非常高的,尤其是这个http那么在近几年我们看到从零七年、零八年、零九年这个绿色的曲线就是这个nginx的市场占有,那么nginx 这个占有率呢慢慢的一直在提升。 那么为什么会有越来越多的企业会用index,甚至把http、db慢慢地用nginx来作为替换呢? 这里面一定是有它的原因。 那么接下来的课程呢我将为大家介绍一下index为什么会受到大家的喜欢。
2-3 Nginx优势多路IO复用 (09:44)
那么我们选择nginx作为我们的中间件和代理服务,一定有着自己喜欢的原因。如我们喜欢每一样东西也是一样的道理。那么这节课呢我们就来讲一讲nginx。
被大家所广泛喜欢的原因,我们为什么选择nginx以及它到底有哪一些共性的优势?
首先呢就是它采用的是io多路复用的这项技术。
i o 多路复用,我们先来给大家讲一讲什么是i o 复用。
其实i o 复用解决的就是一个并发性的问题。正如我们所大家所看的慕课网一样,大家都在听说慕课网这个时候对服务端后台而言就会产生多个请求。
处理多个并发的请求,对于中间件就要产生多个i o 流,对于系统的读写。
那么对于i o 流请求,操作系统内核有并行处理和串行处理这么一个概念。串行处理的方式我们是一个一个处理前一个如果发生阻塞。
那么后面的就没法完成整个请求。所以这个时候呢我们就必须得考虑并行的方式来完成整个i o 流的请求。你实现最大的并发和吞吐。
这个时候呢就用到了i o 复用的技术,i o 复用的技术呢就是让一个socket 来作为复用,完成整个i o 流的请求。
当然实现整个i o 流的这个请求由我图形的画到的其中的一种方式,多线程的方式就是其中的一种那么除了多线程的方式还有哪一些呢?以及有什么样的区别呢?
那么就是我们讲到的i o 多路复用。那么说到i o 多路复用,可能有些同学们又会有一些不清楚了。我们来举一个形象的例子。
在教室里边,一个老师同时给学生们做一道题目。
那么你要来检查每一个学生是否做的正确。
这个时候呢老师可以选择我一个学生一个学生的去问同学是否做。
如果同学没a 学生没做完呢,再继续问b 学生,b 学生没做完呢,再继续往下问。那么一个一个问,如果发现问到某个学生,某一个学生说做完的时候。
这个时候呢再去跟这个学生解答。那么这个时候同学们会不会发现,如果一个学生发生阻塞。
阻塞在一个学生里面,有的学生不会那么呢这个老师呢跟他解答半天,其他学生是不是都闲住了。这个时候对整个课堂的效率是不是就
非常有限。
所以这种请求的方式我们可以理解成是一种。
串行的方式来进行这个请求的处理。
那么实现多路复用呢?
我们来举一个场景,同样是一个老师要给学生来出题,让学生来解答。
那么出完一道题目以后呢,这个老师呢学会了分身术一下,把自己分成了多个人,让这多个人呢分别对应的去监听一个学生。
守在一个学生旁边,看这个学生是否答题,完答完了就马上进行解答。这个效率呢是不是更高?
这种方式呢就是一种多线程的方式来进行i o 流的处理。但是多线程的i o 流处理呢会产生一定的消耗。你想想我一个老师,我要分成多个老师。
我要管理这多个老师,本身就存在一个资源的问题。所以这个时候呢
我们到了i o 的多路复用,多路复用的话,在这个场景里边其实改为了由学生来主动上报。
比如说出完题以后,学生B说我已经答完了。这个时候老师再过去解答问题,其他的学生在等待,因为学生b 呢。
他的学习效率高,所以他答的非常快。其他的学生呢可能还在做题。那么等学生b 答完了以后再去学生a 又贡献出了老师的这个。
空闲在自己的解答学生a 的资源。这样的话是不是有了学生的主动上报的这个机制?
那么整个课堂里面就会活跃很多,而且效率会是非常快的。所以这种方式呢就是i o 多路复用的方式,那么。
多路分佣。
有一个特点,就是学生呢会主动上报啊。
对于我们的操作系统内核而言,i o 多路复用其实就是要完成操作系统的i o 的请求。对于i o 文件的这个请求。
我们当一个i o流要进行对应的文件处理的时候,要获取一组文件的描述服务。那么当文件服务描述服务还没有就绪时。
那么他就在等待,直到描述符一旦就绪,马上上报系统的一个通知的记录告诉应用程序,我已经准备就绪了。
你可以来操作了这种方式呢就是i o 多路复用的方式。所以有了这种系统内部通知的方式,处理起来性能就会非常高效。
多路复用其实就是在一个线程里面,同样是只用了一个线程交替并发的完成。 这个呢就叫做i o 的多路复用,复用的呢就是一个线程。
好,那么我们接下来讲一下i o 多路复用epoll。
那么epoll 和select poll 是links 下面常见的内核的i o 多路复用模型。
那么最早出现的呢是select 在links 下,我们讲过了安茹多路复用呢,其实就是内核态对于i o 请求的时候主动发送。
所需要处理的文件对象就绪时呢,会发送对应的文件,可用信息给应用这一端。
那么应用这一端呢,其实在整个这个f d 没有就绪之前呢,都是block 住的,也就是阻塞住对应的socket 请求。
那么也会维护呢一个f d 的这个列表。
当内核态发送可用的这个f d 就去以后,整个应用端呢采用select 的这个模式呢会一直在不断的遍历。
所维护的这个f d 的文件描述符的这个列表。
你等到唤醒对应的进程去完成对应的数据拷贝。
所以在这个过程中。
select 模型呢采用的是线性遍历的这种方式。这种方式存在一个问题,它会不断的去遍历这个队列里面的内容,从而能效率低下。另外一个方面呢,他对于文件描述符的限制呢是存在最大的限制的。那么最大的限制呢是1024个。
在2.6的内核以后,出来了一块模型,epoll正好的优化了这一点。他呢他每一个f d 就绪的时候呢。
采用系统的回调函数,直接将f d 放入到对应的正确的列表,效率呢非常高。
所以epoll模型呢在效率上面呢会比slack 模型呢更加好。
另外一件呢,它没有最大连接数的一个限制。
举一个常用的例子呢,就是当我们在饭馆里边结账的时候,我们会通知服务员,服务员呢会告诉老板老板然后过来结账。
我们告诉服务员,我们已经用餐准备结账的时候,服务员告诉老板说有几桌准备结账,但是不告诉老板是哪几桌。那么这个时候呢,老板就需要对应的去问去问。
是哪几桌?所以这个方式呢是select 的模型的方式,而epoll的模型的方式是什么样子的。
同样是结账,我们告诉服务员,我们要结账,但是服务员呢会负责任的把哪几号桌需要结账,告诉老板,老板呢就直接到对应的几号桌去结账。
所以这样的效率呢是比较高的。nginx呢就是采用了epoll模型来实现它最高的处理文件的效率
2-4 Nginx使用Epoll模型的优势介绍 (08:48)
那么我们一直会说一个服务轻量级,那么主要是指的什么呢?
通常我们会是指功能模块少,另外呢就是代码模块化。
那么在nginx的服务里面呢,其实我们就是认为nginx是一个足够轻量级的web服务,那么尽量集它的功能模块小体现在它的源代码里面,只保留了跟http以及它相关核心功能的那一部分核心模块的代码,那么一些不够核心,或者是一些类似于可以作为插件式的来进行安装的,那么不会被集成在nginx的源代码里面。
那么这样的话一个好处也是主要出于它的性能考虑。
那么这样的也会有一些不足的地方,就是它不会像类似于http d。
就是阿帕奇的这个web server这种服务一样,没有那么全或者是没有那么丰富的一些插件或者是功能,所以这个是nginx作为轻量级,充分考虑它的性能优势的一个优点的一个地方。
当然另外一个的话就是代码模块化,模块化的代码我们一个是意图,另外一个方面的话也是对nginx的代码进行一些二次的改进,这样的话是对于开发人员来说是非常友好的。
所以nginx在国内的话有阿里的png,那么其实就是基于nginx1.6的这个版本呢进行的二次的开发,现在呢已经由阿里开源成了tng的这个版本。
好,那么这个呢就是nginx这个词的第二个优点。
轻量级。
2-5 Nginx-CPU亲和 (02:14)
我们再来讲一讲c p u 的亲和nginx 真是利用到了c p u 的亲和来提升它的并发处理能力和对于c p u 的工作实习效率,减少不必要的额外性能损耗。
那么他这个c p u 的亲和为什么需要c p u 的亲和?
首先我们来讲一讲我们的服务器配置。当今的服务器。
二十四核三十二核、六十四核这种核心的服务器,我们已经见怪不怪了。
那么这种。
多核多性能,多核的服务器里面往往被用在多线程工作密集计算型的服务里面去使用。
那么nginx 作为一个接入层的中间件,它对于c p u 的亲和就尤为重要。那么他是怎么工作的呢?
其实很简单,nginx 它是有多个不同的worker 的进程去进行处理。假设我有一台服务器,有双c p u。
然后呢每一个c p u 有四个核心。
然后呢我们把c p u 的八个工作进程分别绑定到不同的c p u 上。也就是我分配你这个进程。
处理在一个c p u 上处理你这个worker 的进程呢,放在另外一个c p u 上处理这样的分配。
就能有什么样的好处呢?我们在想,如果是有多个c p u 利用到它自动的切换模式的话,这样的话就会造成c p u 切换所带来的。
一些性能的损失。那么利用这种c p u 的亲和的这种绑定方式,就能减少额外的性能损耗。
那么亲和其实我们可以把它理解成就是把c p u 的核心大家知道是c p u 的核心和nginx 的工作进程
进行绑定,也就是把每一个worker 的进程固定到一个c p u 上去进行执行,减少c p u 的cache miss
或者很好的性能。
2-6 Nginx-sendfile (01:46)
然后另外一个我们要来讲的就是nginx的sendfile
我们都知道nginx在处理静态文件的效率是非常有优势的。那么为什么呢?这是因为nginx采用了sendfile
工作的机制。那么我们来对比原来的h tt p 的server 的服务呢采用的是什么样的机制来传输文件。那这里呢我画了一个。
示意图。当我们去请求一个文件的时候。
他要经过操作系统的内核空间和用户空间最终到达socket
通过socket再传递response 给用户。那么对于一台服务器而言,操作系统而言,它经过内核。
空间到用户空间,也就是说要发生多次的切换。那么我们就知道静态文件其实不需要经过过多的用户空间的。
逻辑性的处理直接就可以通过内核空间进行传输。所以sendfile正是利用到了。
这种模式也就是linux 在2.2以后出来的零拷贝这种传输模。
用把所有的这个文件的传输只通过内核空间传递给socket 响应给用户。
那么我们在对于nginx。
在很多c d n 的服务里面,或者是在处理做动静分离的静态文件的处理,n g s 的处理性会比较。
其他的服务呢都要高很多。那么这个呢就是nginx的一大优点。
2-7 Nginx快速安装 (05:43)
yum部署Nginx方式
那么接下来呢我们带大家一起来安装nginx。
nginx安装之前呢,我们得了解安全使用哪些版本。
一个呢是维护版本,也就是开发版。开发版的往往是具有最新功能,最新的代码的版本,这个呢是提供给大家,主要是用于测试研究。
学习更不建议您呢用于呢企业的实际的生产环境。那么在开发版本过渡的期间呢,会不断的更新稳定版本。稳定版本呢。
是官方认可的,而且是运行经过测试的。所以在企业的实际生产环境中呢,会用到稳定版本。那么对于历史的稳定版本呢。
官方呢会进行收集,放到了历史的这个版本里面去,叫做 legacy version 这几个版本信息呢在nginx 官网里面都会按大力列出来了。
http://nginx.org/en/download.html
我们可以登录到nginx官方网站。接下来我们打开浏览器,登录到nginx官方网站,只需要输入输入一个nginx
在左侧有一个download的。
这样的话我们进入到了download 界面。在这个界面里面呢,我们大的部分在里面来看nginxdownload 这一类表示的是现在我们可以下载的一些版本内容。
source code 主要是nginx的源代码,相关的维护,你的一些情况在这两个站点里面我们都可以看到对应的一些源代码提交以及修改记录。
等等,这个呢是我们想要通过一些系统的安装方式。比如说样本一般yum上面的a p p 等等yum的方式来进行安装。
我们呢就可以点击对应的页面去安装。那么这节课呢我们的安装方式呢就是基于样本的方式来装。首先呢我们回到最前面,最前面呢会出现我们刚讲过的三个版本。
http://nginx.org/en/linux_packages.html#RHEL-CentOS
yum部署Nginx方式后的 nginx 启动、重启、终止、开机自启、禁止开机自启
安装完成之后,即可通过system对其进行管理:
systemctl start nginx #启动 systemctl restart nginx #重启 systemctl stop nginx #终止 systemctl enable nginx #开机自启 systemctl disable nginx #禁止开机自启
但yum部署Nginx的方式有一个明显的缺陷——无法自定义模块,如果需要这一功能,必须使用源码部署。
[root@localhost ~]# yum list all [root@localhost ~]# ping www.baidu.com [root@localhost backups]# iptables -L #查看防火墙 [root@localhost backups]# iptables -F #关闭防火墙 [root@localhost backups]# iptables -t nat -L [root@localhost backups]# iptables -t nat -F [root@localhost backups]# getenforce # 查看 setlinux [root@localhost backups]# setenforce 0 # 关闭 setlinux [root@localhost backups]# getenforce # 安装 yum 包 [root@localhost ~]# yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake [root@localhost ~]# yum -y install wget httpd-tools vim [root@localhost ~]# yum install gcc-c++ [root@localhost ~]# yum install -y pcre pcre-devel [root@localhost ~]# yum install -y openssl openssl-devel [root@localhost ~]# yum install -y zlib zlib-devel [root@localhost ~]# ls anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Desktop Downloads Music Public Videos [root@localhost ~]# cd /opt [root@localhost opt]# ls rh [root@localhost opt]# cd /opt;mkdir app download logs work backup [root@localhost opt]# ls app backup download logs rh work [root@localhost etc]# cd yum.repos.d/ [root@localhost yum.repos.d]# ls backups CentOS-fasttrack.repo CentOS-Sources.repo CentOS-Base.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-SCLo-scl.repo CentOS-x86_64-kernel.repo CentOS-Debuginfo.repo CentOS-SCLo-scl-rh.repo [root@localhost yum.repos.d]# pwd /etc/yum.repos.d [root@localhost yum.repos.d]# vim 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 [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# sudo yum install nginx Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.bupt.edu.cn * centos-sclo-rh: mirrors.dgut.edu.cn * centos-sclo-sclo: mirrors.bupt.edu.cn * extras: mirrors.dgut.edu.cn * updates: mirrors.nju.edu.cn Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.20.1-1.el7.ngx will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================= Package Arch Version Repository Size ========================================================================================= Installing: nginx x86_64 1:1.20.1-1.el7.ngx nginx-stable 790 k Transaction Summary ========================================================================================= Install 1 Package Total download size: 790 k Installed size: 2.8 M Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.20.1-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY Public key for nginx-1.20.1-1.el7.ngx.x86_64.rpm is not installed nginx-1.20.1-1.el7.ngx.x86_64.rpm | 790 kB 00:01:05 Retrieving key from https://nginx.org/keys/nginx_signing.key Importing GPG key 0x7BD9BF62: Userid : "nginx signing key <signing-key@nginx.com>" Fingerprint: 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62 From : https://nginx.org/keys/nginx_signing.key Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:nginx-1.20.1-1.el7.ngx.x86_64 1/1 ---------------------------------------------------------------------- Thanks for using nginx! Please find the official documentation for nginx here: * https://nginx.org/en/docs/ Please subscribe to nginx-announce mailing list to get the most important news about nginx: * https://nginx.org/en/support.html Commercial subscriptions for nginx are available on: * https://nginx.com/products/ ---------------------------------------------------------------------- Verifying : 1:nginx-1.20.1-1.el7.ngx.x86_64 1/1 Installed: nginx.x86_64 1:1.20.1-1.el7.ngx Complete! [root@192 ~]# cd /etc/nginx/ [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# pwd /etc/nginx [root@192 nginx]# nginx -v #查看 nginx 版本 nginx version: nginx/1.20.1 [root@192 nginx]# nginx -v nginx version: nginx/1.20.1 [root@192 nginx]#
安装包方式部署安装Nginx方式
文章转自:https://www.cnblogs.com/liujuncm5/p/6713784.html
安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
官网下载
1.直接下载
.tar.gz
安装包,地址:https://nginx.org/en/download.html http://nginx.org/en/download.html
2.使用
wget
命令下载(推荐)。确保系统已经安装了wget,如果没有安装,执行 yum install wget 安装。
wget -c https://nginx.org/download/nginx-1.20.0.tar.gz
我下载的是1.20.0版本,这个是目前的稳定版。
解压
依然是直接命令:
tar -zxvf nginx-1.20.0.tar.gz
cd nginx-1.20.0/
配置
其实在 nginx-1.20.0 版本中你就不需要去配置相关东西,默认就可以了。当然,如果你要自己配置目录也是可以的。
1.使用默认配置./configure
2.自定义配置(不推荐)
./configure \ --prefix=/usr/local/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --pid-path=/usr/local/nginx/conf/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi
注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
编译安装
make make install
查找安装路径:
whereis nginx
启动、停止nginx
cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
启动时报80端口被占用:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
解决办法:1、安装net-tool 包:
yum install net-tools
./nginx -s quit
:此方式停止步骤是待nginx进程处理任务完毕进行停止。./nginx -s stop
:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。查询nginx进程:
ps aux|grep nginx
重启 nginx
1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit ./nginx
2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload
不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload启动成功后,在浏览器可以看到这样的页面:
开机自启动
即在
rc.local
增加启动代码就可以了。
vi /etc/rc.local
增加一行
/usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 rc.local
到这里,nginx就安装完毕了,启动、停止、重启操作也都完成了,当然,你也可以添加为系统服务,我这里就不在演示了。
View CodeLast failed login: Sun Nov 7 14:35:16 CST 2021 from 192.168.0.10 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Sun Nov 7 11:23:33 2021 [root@192 ~]# yum install gcc-c++ Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version Nothing to do [root@192 ~]# [root@192 ~]# yum install -y pcre pcre-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package pcre-8.32-17.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: pcre-devel x86_64 8.32-17.el7 base 480 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Total download size: 480 k Installed size: 1.4 M Downloading packages: pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pcre-devel-8.32-17.el7.x86_64 1/1 Verifying : pcre-devel-8.32-17.el7.x86_64 1/1 Installed: pcre-devel.x86_64 0:8.32-17.el7 Complete! [root@192 ~]# yum install -y zlib zlib-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package zlib.x86_64 0:1.2.7-18.el7 will be updated ---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update ---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: zlib-devel x86_64 1.2.7-19.el7_9 updates 50 k Updating: zlib x86_64 1.2.7-19.el7_9 updates 90 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Upgrade 1 Package Total size: 140 k Total download size: 50 k Downloading packages: zlib-devel-1.2.7-19.el7_9.x86_64.rpm | 50 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : zlib-1.2.7-19.el7_9.x86_64 1/3 Installing : zlib-devel-1.2.7-19.el7_9.x86_64 2/3 Cleanup : zlib-1.2.7-18.el7.x86_64 3/3 Verifying : zlib-devel-1.2.7-19.el7_9.x86_64 1/3 Verifying : zlib-1.2.7-19.el7_9.x86_64 2/3 Verifying : zlib-1.2.7-18.el7.x86_64 3/3 Installed: zlib-devel.x86_64 0:1.2.7-19.el7_9 Updated: zlib.x86_64 0:1.2.7-19.el7_9 Complete! [root@192 ~]# yum install -y openssl openssl-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package openssl.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl.x86_64 1:1.0.2k-21.el7_9 will be an update --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-21.el7_9 for package: 1:openssl-1.0.2k-21.el7_9.x86_64 ---> Package openssl-devel.x86_64 1:1.0.2k-21.el7_9 will be installed --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64 --> Running transaction check ---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl-libs.x86_64 1:1.0.2k-21.el7_9 will be an update --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed ---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed --> Running transaction check ---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: openssl-devel x86_64 1:1.0.2k-21.el7_9 updates 1.5 M Updating: openssl x86_64 1:1.0.2k-21.el7_9 updates 493 k Installing for dependencies: keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-50.el7 base 273 k libcom_err-devel x86_64 1.42.9-19.el7 base 32 k libselinux-devel x86_64 2.5-15.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libverto-devel x86_64 0.2.5-4.el7 base 12 k Updating for dependencies: openssl-libs x86_64 1:1.0.2k-21.el7_9 updates 1.2 M Transaction Summary ============================================================================================================================================================================ Install 1 Package (+6 Dependent packages) Upgrade 1 Package (+1 Dependent package) Total size: 3.8 M Total download size: 2.1 M Downloading packages: (1/7): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00 (2/7): libcom_err-devel-1.42.9-19.el7.x86_64.rpm | 32 kB 00:00:00 (3/7): krb5-devel-1.15.1-50.el7.x86_64.rpm | 273 kB 00:00:00 (4/7): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00 (5/7): libselinux-devel-2.5-15.el7.x86_64.rpm | 187 kB 00:00:00 (6/7): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00 (7/7): openssl-devel-1.0.2k-21.el7_9.x86_64.rpm | 1.5 MB 00:00:01 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.1 MB/s | 2.1 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 1/11 Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 2/11 Installing : libcom_err-devel-1.42.9-19.el7.x86_64 3/11 Installing : libverto-devel-0.2.5-4.el7.x86_64 4/11 Installing : libsepol-devel-2.5-10.el7.x86_64 5/11 Installing : libselinux-devel-2.5-15.el7.x86_64 6/11 Installing : krb5-devel-1.15.1-50.el7.x86_64 7/11 Installing : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 8/11 Updating : 1:openssl-1.0.2k-21.el7_9.x86_64 9/11 Cleanup : 1:openssl-1.0.2k-19.el7.x86_64 10/11 Cleanup : 1:openssl-libs-1.0.2k-19.el7.x86_64 11/11 Verifying : libsepol-devel-2.5-10.el7.x86_64 1/11 Verifying : libselinux-devel-2.5-15.el7.x86_64 2/11 Verifying : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 3/11 Verifying : libverto-devel-0.2.5-4.el7.x86_64 4/11 Verifying : krb5-devel-1.15.1-50.el7.x86_64 5/11 Verifying : libcom_err-devel-1.42.9-19.el7.x86_64 6/11 Verifying : 1:openssl-1.0.2k-21.el7_9.x86_64 7/11 Verifying : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 8/11 Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 9/11 Verifying : 1:openssl-1.0.2k-19.el7.x86_64 10/11 Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 11/11 Installed: openssl-devel.x86_64 1:1.0.2k-21.el7_9 Dependency Installed: keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7 libcom_err-devel.x86_64 0:1.42.9-19.el7 libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 Updated: openssl.x86_64 1:1.0.2k-21.el7_9 Dependency Updated: openssl-libs.x86_64 1:1.0.2k-21.el7_9 Complete! [root@192 ~]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) [root@192 ~]# yum install -y openssl openssl-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package 1:openssl-1.0.2k-21.el7_9.x86_64 already installed and latest version Package 1:openssl-devel-1.0.2k-21.el7_9.x86_64 already installed and latest version Nothing to do [root@192 ~]# yum install -y zlib zlib-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package zlib-1.2.7-19.el7_9.x86_64 already installed and latest version Package zlib-devel-1.2.7-19.el7_9.x86_64 already installed and latest version Nothing to do [root@192 ~]# cat /usr/lib64/pkgconfig/zlib.pc prefix=/usr exec_prefix=${prefix} libdir=/usr/lib64 sharedlibdir=${libdir} includedir=/usr/include Name: zlib Description: zlib compression library Version: 1.2.7 Requires: Libs: -L${libdir} -L${sharedlibdir} -lz Cflags: -I${includedir} [root@192 ~]# yum install -y pcre pcre-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package pcre-8.32-17.el7.x86_64 already installed and latest version Package pcre-devel-8.32-17.el7.x86_64 already installed and latest version Nothing to do [root@192 ~]# pcre-config --version 8.32 [root@192 ~]# cd export/install -bash: cd: export/install: No such file or directory [root@192 ~]# mkdir -p export/install [root@192 ~]# ls anaconda-ks.cfg Desktop Documents Downloads export initial-setup-ks.cfg Music Pictures Public Templates Videos [root@192 ~]# Connection was reset. Last login: Sun Nov 7 11:23:33 2021 [root@192 ~]# [root@192 ~]# yum install gcc-c++ Loaded plugins: fastestmirror, langpacks Existing lock /var/run/yum.pid: another copy is running as pid 3095. Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 179 M RSS (629 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:23 ago State : Running, pid: 3095 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 179 M RSS (629 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:25 ago State : Running, pid: 3095 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 155 M RSS (593 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:27 ago State : Running, pid: 3095 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 160 M RSS (598 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:29 ago State : Running, pid: 3095 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 160 M RSS (599 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:31 ago State : Sleeping, pid: 3095 ^C Exiting on user cancel. [root@192 ~]# yum -y install gcc* Loaded plugins: fastestmirror, langpacks Existing lock /var/run/yum.pid: another copy is running as pid 3095. Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 161 M RSS (599 MB VSZ) Started: Sun Nov 7 14:42:27 2021 - 02:54 ago State : Sleeping, pid: 3095 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package gcc-4.8.5-44.el7.x86_64 already installed and latest version Package gcc-gfortran-4.8.5-44.el7.x86_64 already installed and latest version Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package gcc-gnat.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libgnat-devel = 4.8.5-44.el7 for package: gcc-gnat-4.8.5-44.el7.x86_64 --> Processing Dependency: libgnat = 4.8.5-44.el7 for package: gcc-gnat-4.8.5-44.el7.x86_64 ---> Package gcc-go.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libgo-devel = 4.8.5-44.el7 for package: gcc-go-4.8.5-44.el7.x86_64 --> Processing Dependency: libgo = 4.8.5-44.el7 for package: gcc-go-4.8.5-44.el7.x86_64 ---> Package gcc-objc.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libobjc = 4.8.5-44.el7 for package: gcc-objc-4.8.5-44.el7.x86_64 --> Processing Dependency: libobjc.so.4()(64bit) for package: gcc-objc-4.8.5-44.el7.x86_64 ---> Package gcc-objc++.x86_64 0:4.8.5-44.el7 will be installed ---> Package gcc-plugin-devel.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: mpfr-devel >= 2.2.1 for package: gcc-plugin-devel-4.8.5-44.el7.x86_64 --> Processing Dependency: libmpc-devel >= 0.8.1 for package: gcc-plugin-devel-4.8.5-44.el7.x86_64 --> Processing Dependency: gmp-devel >= 4.1.2-8 for package: gcc-plugin-devel-4.8.5-44.el7.x86_64 --> Running transaction check ---> Package gmp-devel.x86_64 1:6.0.0-15.el7 will be installed ---> Package libgnat.x86_64 0:4.8.5-44.el7 will be installed ---> Package libgnat-devel.x86_64 0:4.8.5-44.el7 will be installed ---> Package libgo.x86_64 0:4.8.5-44.el7 will be installed ---> Package libgo-devel.x86_64 0:4.8.5-44.el7 will be installed ---> Package libmpc-devel.x86_64 0:1.0.1-3.el7 will be installed ---> Package libobjc.x86_64 0:4.8.5-44.el7 will be installed ---> Package mpfr-devel.x86_64 0:3.1.1-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: gcc-gnat x86_64 4.8.5-44.el7 base 13 M gcc-go x86_64 4.8.5-44.el7 base 5.9 M gcc-objc x86_64 4.8.5-44.el7 base 5.7 M gcc-objc++ x86_64 4.8.5-44.el7 base 6.2 M gcc-plugin-devel x86_64 4.8.5-44.el7 base 828 k Installing for dependencies: gmp-devel x86_64 1:6.0.0-15.el7 base 181 k libgnat x86_64 4.8.5-44.el7 base 967 k libgnat-devel x86_64 4.8.5-44.el7 base 2.7 M libgo x86_64 4.8.5-44.el7 base 2.2 M libgo-devel x86_64 4.8.5-44.el7 base 231 k libmpc-devel x86_64 1.0.1-3.el7 base 32 k libobjc x86_64 4.8.5-44.el7 base 80 k mpfr-devel x86_64 3.1.1-4.el7 base 68 k Transaction Summary ============================================================================================================================================================================ Install 5 Packages (+8 Dependent packages) Total download size: 38 M Installed size: 119 M Downloading packages: (1/13): gcc-objc-4.8.5-44.el7.x86_64.rpm | 5.7 MB 00:00:06 (2/13): gcc-go-4.8.5-44.el7.x86_64.rpm | 5.9 MB 00:00:07 (3/13): gcc-plugin-devel-4.8.5-44.el7.x86_64.rpm | 828 kB 00:00:00 (4/13): gcc-gnat-4.8.5-44.el7.x86_64.rpm | 13 MB 00:00:12 (5/13): gcc-objc++-4.8.5-44.el7.x86_64.rpm | 6.2 MB 00:00:05 (6/13): gmp-devel-6.0.0-15.el7.x86_64.rpm | 181 kB 00:00:00 (7/13): libgnat-4.8.5-44.el7.x86_64.rpm | 967 kB 00:00:00 (8/13): libgo-4.8.5-44.el7.x86_64.rpm | 2.2 MB 00:00:01 (9/13): libmpc-devel-1.0.1-3.el7.x86_64.rpm | 32 kB 00:00:00 (10/13): libgo-devel-4.8.5-44.el7.x86_64.rpm | 231 kB 00:00:00 (11/13): mpfr-devel-3.1.1-4.el7.x86_64.rpm | 68 kB 00:00:00 (12/13): libobjc-4.8.5-44.el7.x86_64.rpm | 80 kB 00:00:00 (13/13): libgnat-devel-4.8.5-44.el7.x86_64.rpm | 2.7 MB 00:00:01 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.6 MB/s | 38 MB 00:00:14 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:gmp-devel-6.0.0-15.el7.x86_64 1/13 Installing : mpfr-devel-3.1.1-4.el7.x86_64 2/13 Installing : libgo-4.8.5-44.el7.x86_64 3/13 Installing : libgo-devel-4.8.5-44.el7.x86_64 4/13 Installing : libmpc-devel-1.0.1-3.el7.x86_64 5/13 Installing : libobjc-4.8.5-44.el7.x86_64 6/13 Installing : gcc-objc-4.8.5-44.el7.x86_64 7/13 Installing : libgnat-4.8.5-44.el7.x86_64 8/13 Installing : libgnat-devel-4.8.5-44.el7.x86_64 9/13 Installing : gcc-gnat-4.8.5-44.el7.x86_64 10/13 Installing : gcc-objc++-4.8.5-44.el7.x86_64 11/13 Installing : gcc-plugin-devel-4.8.5-44.el7.x86_64 12/13 Installing : gcc-go-4.8.5-44.el7.x86_64 13/13 Verifying : gcc-gnat-4.8.5-44.el7.x86_64 1/13 Verifying : libmpc-devel-1.0.1-3.el7.x86_64 2/13 Verifying : libgnat-devel-4.8.5-44.el7.x86_64 3/13 Verifying : libgo-4.8.5-44.el7.x86_64 4/13 Verifying : libgnat-4.8.5-44.el7.x86_64 5/13 Verifying : mpfr-devel-3.1.1-4.el7.x86_64 6/13 Verifying : 1:gmp-devel-6.0.0-15.el7.x86_64 7/13 Verifying : libgo-devel-4.8.5-44.el7.x86_64 8/13 Verifying : gcc-plugin-devel-4.8.5-44.el7.x86_64 9/13 Verifying : gcc-objc-4.8.5-44.el7.x86_64 10/13 Verifying : libobjc-4.8.5-44.el7.x86_64 11/13 Verifying : gcc-objc++-4.8.5-44.el7.x86_64 12/13 Verifying : gcc-go-4.8.5-44.el7.x86_64 13/13 Installed: gcc-gnat.x86_64 0:4.8.5-44.el7 gcc-go.x86_64 0:4.8.5-44.el7 gcc-objc.x86_64 0:4.8.5-44.el7 gcc-objc++.x86_64 0:4.8.5-44.el7 gcc-plugin-devel.x86_64 0:4.8.5-44.el7 Dependency Installed: gmp-devel.x86_64 1:6.0.0-15.el7 libgnat.x86_64 0:4.8.5-44.el7 libgnat-devel.x86_64 0:4.8.5-44.el7 libgo.x86_64 0:4.8.5-44.el7 libgo-devel.x86_64 0:4.8.5-44.el7 libmpc-devel.x86_64 0:1.0.1-3.el7 libobjc.x86_64 0:4.8.5-44.el7 mpfr-devel.x86_64 0:3.1.1-4.el7 Complete! [root@192 ~]# yum install -y pcre pcre-devel Loaded plugins: fastestmirror, langpacks Existing lock /var/run/yum.pid: another copy is running as pid 4880. Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 62 M RSS (425 MB VSZ) Started: Sun Nov 7 14:45:22 2021 - 00:36 ago State : Sleeping, pid: 4880 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 62 M RSS (425 MB VSZ) Started: Sun Nov 7 14:45:22 2021 - 00:38 ago State : Sleeping, pid: 4880 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package pcre-8.32-17.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: pcre-devel x86_64 8.32-17.el7 base 480 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Total download size: 480 k Installed size: 1.4 M Downloading packages: pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pcre-devel-8.32-17.el7.x86_64 1/1 Verifying : pcre-devel-8.32-17.el7.x86_64 1/1 Installed: pcre-devel.x86_64 0:8.32-17.el7 Complete! [root@192 ~]# yum install -y zlib zlib-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package zlib.x86_64 0:1.2.7-18.el7 will be updated ---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update ---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: zlib-devel x86_64 1.2.7-19.el7_9 updates 50 k Updating: zlib x86_64 1.2.7-19.el7_9 updates 90 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Upgrade 1 Package Total size: 140 k Total download size: 50 k Downloading packages: zlib-devel-1.2.7-19.el7_9.x86_64.rpm | 50 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : zlib-1.2.7-19.el7_9.x86_64 1/3 Installing : zlib-devel-1.2.7-19.el7_9.x86_64 2/3 Cleanup : zlib-1.2.7-18.el7.x86_64 3/3 Verifying : zlib-devel-1.2.7-19.el7_9.x86_64 1/3 Verifying : zlib-1.2.7-19.el7_9.x86_64 2/3 Verifying : zlib-1.2.7-18.el7.x86_64 3/3 Installed: zlib-devel.x86_64 0:1.2.7-19.el7_9 Updated: zlib.x86_64 0:1.2.7-19.el7_9 Complete! [root@192 ~]# yum install -y openssl openssl-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package openssl.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl.x86_64 1:1.0.2k-21.el7_9 will be an update --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-21.el7_9 for package: 1:openssl-1.0.2k-21.el7_9.x86_64 ---> Package openssl-devel.x86_64 1:1.0.2k-21.el7_9 will be installed --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64 --> Running transaction check ---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl-libs.x86_64 1:1.0.2k-21.el7_9 will be an update --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed ---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed --> Running transaction check ---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: openssl-devel x86_64 1:1.0.2k-21.el7_9 updates 1.5 M Updating: openssl x86_64 1:1.0.2k-21.el7_9 updates 493 k Installing for dependencies: keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-50.el7 base 273 k libcom_err-devel x86_64 1.42.9-19.el7 base 32 k libselinux-devel x86_64 2.5-15.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libverto-devel x86_64 0.2.5-4.el7 base 12 k Updating for dependencies: openssl-libs x86_64 1:1.0.2k-21.el7_9 updates 1.2 M Transaction Summary ============================================================================================================================================================================ Install 1 Package (+6 Dependent packages) Upgrade 1 Package (+1 Dependent package) Total size: 3.8 M Total download size: 2.1 M Downloading packages: (1/7): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00 (2/7): libcom_err-devel-1.42.9-19.el7.x86_64.rpm | 32 kB 00:00:00 (3/7): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00 (4/7): krb5-devel-1.15.1-50.el7.x86_64.rpm | 273 kB 00:00:00 (5/7): libselinux-devel-2.5-15.el7.x86_64.rpm | 187 kB 00:00:00 (6/7): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00 (7/7): openssl-devel-1.0.2k-21.el7_9.x86_64.rpm | 1.5 MB 00:00:01 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 907 kB/s | 2.1 MB 00:00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 1/11 Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 2/11 Installing : libcom_err-devel-1.42.9-19.el7.x86_64 3/11 Installing : libverto-devel-0.2.5-4.el7.x86_64 4/11 Installing : libsepol-devel-2.5-10.el7.x86_64 5/11 Installing : libselinux-devel-2.5-15.el7.x86_64 6/11 Installing : krb5-devel-1.15.1-50.el7.x86_64 7/11 Installing : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 8/11 Updating : 1:openssl-1.0.2k-21.el7_9.x86_64 9/11 Cleanup : 1:openssl-1.0.2k-19.el7.x86_64 10/11 Cleanup : 1:openssl-libs-1.0.2k-19.el7.x86_64 11/11 Verifying : libsepol-devel-2.5-10.el7.x86_64 1/11 Verifying : libselinux-devel-2.5-15.el7.x86_64 2/11 Verifying : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 3/11 Verifying : libverto-devel-0.2.5-4.el7.x86_64 4/11 Verifying : krb5-devel-1.15.1-50.el7.x86_64 5/11 Verifying : libcom_err-devel-1.42.9-19.el7.x86_64 6/11 Verifying : 1:openssl-1.0.2k-21.el7_9.x86_64 7/11 Verifying : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 8/11 Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 9/11 Verifying : 1:openssl-1.0.2k-19.el7.x86_64 10/11 Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 11/11 Installed: openssl-devel.x86_64 1:1.0.2k-21.el7_9 Dependency Installed: keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7 libcom_err-devel.x86_64 0:1.42.9-19.el7 libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 Updated: openssl.x86_64 1:1.0.2k-21.el7_9 Dependency Updated: openssl-libs.x86_64 1:1.0.2k-21.el7_9 Complete! [root@192 ~]# wget -c https://nginx.org/download/nginx-1.12.0.tar.gz --2021-11-07 14:46:24-- https://nginx.org/download/nginx-1.12.0.tar.gz Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ... Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 980831 (958K) [application/octet-stream] Saving to: ginx-1.12.0.tar.gz 100%[==================================================================================================================================>] 980,831 157KB/s in 5.7s 2021-11-07 14:46:31 (169 KB/s) - ginx-1.12.0.tar.gzsaved [980831/980831] [root@192 ~]# wget -c https://nginx.org/download/nginx-1.20.0.tar.gz --2021-11-07 14:46:48-- https://nginx.org/download/nginx-1.20.0.tar.gz Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ... Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1061070 (1.0M) [application/octet-stream] Saving to: ginx-1.20.0.tar.gz 100%[==================================================================================================================================>] 1,061,070 92.9KB/s in 10s 2021-11-07 14:47:00 (101 KB/s) - ginx-1.20.0.tar.gzsaved [1061070/1061070] [root@192 ~]# ls anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music nginx-1.12.0.tar.gz nginx-1.20.0.tar.gz Pictures Public Templates Videos [root@192 ~]# pwd /root [root@192 ~]# tar -zxvf nginx-1.20.0.tar.gz nginx-1.20.0/ nginx-1.20.0/auto/ nginx-1.20.0/conf/ nginx-1.20.0/contrib/ nginx-1.20.0/src/ nginx-1.20.0/configure nginx-1.20.0/LICENSE nginx-1.20.0/README nginx-1.20.0/html/ nginx-1.20.0/man/ nginx-1.20.0/CHANGES.ru nginx-1.20.0/CHANGES nginx-1.20.0/man/nginx.8 nginx-1.20.0/html/50x.html nginx-1.20.0/html/index.html nginx-1.20.0/src/core/ nginx-1.20.0/src/event/ nginx-1.20.0/src/http/ nginx-1.20.0/src/mail/ nginx-1.20.0/src/misc/ nginx-1.20.0/src/os/ nginx-1.20.0/src/stream/ nginx-1.20.0/src/stream/ngx_stream.c nginx-1.20.0/src/stream/ngx_stream.h nginx-1.20.0/src/stream/ngx_stream_access_module.c nginx-1.20.0/src/stream/ngx_stream_core_module.c nginx-1.20.0/src/stream/ngx_stream_geo_module.c nginx-1.20.0/src/stream/ngx_stream_geoip_module.c nginx-1.20.0/src/stream/ngx_stream_handler.c nginx-1.20.0/src/stream/ngx_stream_limit_conn_module.c nginx-1.20.0/src/stream/ngx_stream_log_module.c nginx-1.20.0/src/stream/ngx_stream_map_module.c nginx-1.20.0/src/stream/ngx_stream_proxy_module.c nginx-1.20.0/src/stream/ngx_stream_realip_module.c nginx-1.20.0/src/stream/ngx_stream_return_module.c nginx-1.20.0/src/stream/ngx_stream_script.c nginx-1.20.0/src/stream/ngx_stream_script.h nginx-1.20.0/src/stream/ngx_stream_set_module.c nginx-1.20.0/src/stream/ngx_stream_split_clients_module.c nginx-1.20.0/src/stream/ngx_stream_ssl_module.c nginx-1.20.0/src/stream/ngx_stream_ssl_module.h nginx-1.20.0/src/stream/ngx_stream_ssl_preread_module.c nginx-1.20.0/src/stream/ngx_stream_upstream.c nginx-1.20.0/src/stream/ngx_stream_upstream.h nginx-1.20.0/src/stream/ngx_stream_upstream_hash_module.c nginx-1.20.0/src/stream/ngx_stream_upstream_least_conn_module.c nginx-1.20.0/src/stream/ngx_stream_upstream_random_module.c nginx-1.20.0/src/stream/ngx_stream_upstream_round_robin.c nginx-1.20.0/src/stream/ngx_stream_upstream_round_robin.h nginx-1.20.0/src/stream/ngx_stream_upstream_zone_module.c nginx-1.20.0/src/stream/ngx_stream_variables.c nginx-1.20.0/src/stream/ngx_stream_variables.h nginx-1.20.0/src/stream/ngx_stream_write_filter_module.c nginx-1.20.0/src/os/unix/ nginx-1.20.0/src/os/unix/ngx_alloc.c nginx-1.20.0/src/os/unix/ngx_alloc.h nginx-1.20.0/src/os/unix/ngx_atomic.h nginx-1.20.0/src/os/unix/ngx_channel.c nginx-1.20.0/src/os/unix/ngx_channel.h nginx-1.20.0/src/os/unix/ngx_daemon.c nginx-1.20.0/src/os/unix/ngx_darwin.h nginx-1.20.0/src/os/unix/ngx_darwin_config.h nginx-1.20.0/src/os/unix/ngx_darwin_init.c nginx-1.20.0/src/os/unix/ngx_darwin_sendfile_chain.c nginx-1.20.0/src/os/unix/ngx_dlopen.c nginx-1.20.0/src/os/unix/ngx_dlopen.h nginx-1.20.0/src/os/unix/ngx_errno.c nginx-1.20.0/src/os/unix/ngx_errno.h nginx-1.20.0/src/os/unix/ngx_file_aio_read.c nginx-1.20.0/src/os/unix/ngx_files.c nginx-1.20.0/src/os/unix/ngx_files.h nginx-1.20.0/src/os/unix/ngx_freebsd.h nginx-1.20.0/src/os/unix/ngx_freebsd_config.h nginx-1.20.0/src/os/unix/ngx_linux.h nginx-1.20.0/src/os/unix/ngx_freebsd_init.c nginx-1.20.0/src/os/unix/ngx_freebsd_sendfile_chain.c nginx-1.20.0/src/os/unix/ngx_gcc_atomic_amd64.h nginx-1.20.0/src/os/unix/ngx_gcc_atomic_ppc.h nginx-1.20.0/src/os/unix/ngx_gcc_atomic_sparc64.h nginx-1.20.0/src/os/unix/ngx_gcc_atomic_x86.h nginx-1.20.0/src/os/unix/ngx_linux_aio_read.c nginx-1.20.0/src/os/unix/ngx_linux_config.h nginx-1.20.0/src/os/unix/ngx_linux_init.c nginx-1.20.0/src/os/unix/ngx_linux_sendfile_chain.c nginx-1.20.0/src/os/unix/ngx_os.h nginx-1.20.0/src/os/unix/ngx_posix_config.h nginx-1.20.0/src/os/unix/ngx_posix_init.c nginx-1.20.0/src/os/unix/ngx_process.c nginx-1.20.0/src/os/unix/ngx_process.h nginx-1.20.0/src/os/unix/ngx_process_cycle.c nginx-1.20.0/src/os/unix/ngx_process_cycle.h nginx-1.20.0/src/os/unix/ngx_readv_chain.c nginx-1.20.0/src/os/unix/ngx_recv.c nginx-1.20.0/src/os/unix/ngx_send.c nginx-1.20.0/src/os/unix/ngx_setaffinity.c nginx-1.20.0/src/os/unix/ngx_setaffinity.h nginx-1.20.0/src/os/unix/ngx_setproctitle.c nginx-1.20.0/src/os/unix/ngx_setproctitle.h nginx-1.20.0/src/os/unix/ngx_shmem.c nginx-1.20.0/src/os/unix/ngx_shmem.h nginx-1.20.0/src/os/unix/ngx_socket.c nginx-1.20.0/src/os/unix/ngx_socket.h nginx-1.20.0/src/os/unix/ngx_solaris.h nginx-1.20.0/src/os/unix/ngx_solaris_config.h nginx-1.20.0/src/os/unix/ngx_solaris_init.c nginx-1.20.0/src/os/unix/ngx_solaris_sendfilev_chain.c nginx-1.20.0/src/os/unix/ngx_sunpro_amd64.il nginx-1.20.0/src/os/unix/ngx_sunpro_atomic_sparc64.h nginx-1.20.0/src/os/unix/ngx_sunpro_sparc64.il nginx-1.20.0/src/os/unix/ngx_thread.h nginx-1.20.0/src/os/unix/ngx_sunpro_x86.il nginx-1.20.0/src/os/unix/ngx_thread_cond.c nginx-1.20.0/src/os/unix/ngx_thread_id.c nginx-1.20.0/src/os/unix/ngx_thread_mutex.c nginx-1.20.0/src/os/unix/ngx_time.c nginx-1.20.0/src/os/unix/ngx_time.h nginx-1.20.0/src/os/unix/ngx_udp_recv.c nginx-1.20.0/src/os/unix/ngx_udp_send.c nginx-1.20.0/src/os/unix/ngx_udp_sendmsg_chain.c nginx-1.20.0/src/os/unix/ngx_user.c nginx-1.20.0/src/os/unix/ngx_user.h nginx-1.20.0/src/os/unix/ngx_writev_chain.c nginx-1.20.0/src/misc/ngx_cpp_test_module.cpp nginx-1.20.0/src/misc/ngx_google_perftools_module.c nginx-1.20.0/src/mail/ngx_mail.c nginx-1.20.0/src/mail/ngx_mail.h nginx-1.20.0/src/mail/ngx_mail_auth_http_module.c nginx-1.20.0/src/mail/ngx_mail_core_module.c nginx-1.20.0/src/mail/ngx_mail_handler.c nginx-1.20.0/src/mail/ngx_mail_imap_handler.c nginx-1.20.0/src/mail/ngx_mail_imap_module.c nginx-1.20.0/src/mail/ngx_mail_imap_module.h nginx-1.20.0/src/mail/ngx_mail_parse.c nginx-1.20.0/src/mail/ngx_mail_pop3_handler.c nginx-1.20.0/src/mail/ngx_mail_pop3_module.c nginx-1.20.0/src/mail/ngx_mail_pop3_module.h nginx-1.20.0/src/mail/ngx_mail_proxy_module.c nginx-1.20.0/src/mail/ngx_mail_realip_module.c nginx-1.20.0/src/mail/ngx_mail_smtp_handler.c nginx-1.20.0/src/mail/ngx_mail_smtp_module.c nginx-1.20.0/src/mail/ngx_mail_smtp_module.h nginx-1.20.0/src/mail/ngx_mail_ssl_module.c nginx-1.20.0/src/mail/ngx_mail_ssl_module.h nginx-1.20.0/src/http/modules/ nginx-1.20.0/src/http/ngx_http.c nginx-1.20.0/src/http/ngx_http.h nginx-1.20.0/src/http/ngx_http_cache.h nginx-1.20.0/src/http/ngx_http_config.h nginx-1.20.0/src/http/ngx_http_copy_filter_module.c nginx-1.20.0/src/http/ngx_http_core_module.c nginx-1.20.0/src/http/ngx_http_core_module.h nginx-1.20.0/src/http/ngx_http_file_cache.c nginx-1.20.0/src/http/ngx_http_header_filter_module.c nginx-1.20.0/src/http/ngx_http_parse.c nginx-1.20.0/src/http/ngx_http_postpone_filter_module.c nginx-1.20.0/src/http/ngx_http_request.c nginx-1.20.0/src/http/ngx_http_request.h nginx-1.20.0/src/http/ngx_http_request_body.c nginx-1.20.0/src/http/ngx_http_script.c nginx-1.20.0/src/http/v2/ nginx-1.20.0/src/http/ngx_http_script.h nginx-1.20.0/src/http/ngx_http_special_response.c nginx-1.20.0/src/http/ngx_http_upstream.c nginx-1.20.0/src/http/ngx_http_upstream.h nginx-1.20.0/src/http/ngx_http_upstream_round_robin.c nginx-1.20.0/src/http/ngx_http_upstream_round_robin.h nginx-1.20.0/src/http/ngx_http_variables.c nginx-1.20.0/src/http/ngx_http_variables.h nginx-1.20.0/src/http/ngx_http_write_filter_module.c nginx-1.20.0/src/http/v2/ngx_http_v2.c nginx-1.20.0/src/http/v2/ngx_http_v2.h nginx-1.20.0/src/http/v2/ngx_http_v2_encode.c nginx-1.20.0/src/http/v2/ngx_http_v2_filter_module.c nginx-1.20.0/src/http/v2/ngx_http_v2_huff_decode.c nginx-1.20.0/src/http/v2/ngx_http_v2_huff_encode.c nginx-1.20.0/src/http/v2/ngx_http_v2_module.c nginx-1.20.0/src/http/v2/ngx_http_v2_module.h nginx-1.20.0/src/http/v2/ngx_http_v2_table.c nginx-1.20.0/src/http/modules/ngx_http_access_module.c nginx-1.20.0/src/http/modules/ngx_http_addition_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_auth_basic_module.c nginx-1.20.0/src/http/modules/ngx_http_auth_request_module.c nginx-1.20.0/src/http/modules/ngx_http_autoindex_module.c nginx-1.20.0/src/http/modules/ngx_http_browser_module.c nginx-1.20.0/src/http/modules/ngx_http_charset_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_chunked_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_dav_module.c nginx-1.20.0/src/http/modules/ngx_http_degradation_module.c nginx-1.20.0/src/http/modules/ngx_http_empty_gif_module.c nginx-1.20.0/src/http/modules/ngx_http_fastcgi_module.c nginx-1.20.0/src/http/modules/perl/ nginx-1.20.0/src/http/modules/ngx_http_flv_module.c nginx-1.20.0/src/http/modules/ngx_http_geo_module.c nginx-1.20.0/src/http/modules/ngx_http_geoip_module.c nginx-1.20.0/src/http/modules/ngx_http_grpc_module.c nginx-1.20.0/src/http/modules/ngx_http_gunzip_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_gzip_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_gzip_static_module.c nginx-1.20.0/src/http/modules/ngx_http_headers_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_image_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_index_module.c nginx-1.20.0/src/http/modules/ngx_http_limit_conn_module.c nginx-1.20.0/src/http/modules/ngx_http_limit_req_module.c nginx-1.20.0/src/http/modules/ngx_http_log_module.c nginx-1.20.0/src/http/modules/ngx_http_map_module.c nginx-1.20.0/src/http/modules/ngx_http_memcached_module.c nginx-1.20.0/src/http/modules/ngx_http_mirror_module.c nginx-1.20.0/src/http/modules/ngx_http_mp4_module.c nginx-1.20.0/src/http/modules/ngx_http_not_modified_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_proxy_module.c nginx-1.20.0/src/http/modules/ngx_http_random_index_module.c nginx-1.20.0/src/http/modules/ngx_http_range_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_realip_module.c nginx-1.20.0/src/http/modules/ngx_http_referer_module.c nginx-1.20.0/src/http/modules/ngx_http_rewrite_module.c nginx-1.20.0/src/http/modules/ngx_http_scgi_module.c nginx-1.20.0/src/http/modules/ngx_http_secure_link_module.c nginx-1.20.0/src/http/modules/ngx_http_slice_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_split_clients_module.c nginx-1.20.0/src/http/modules/ngx_http_ssi_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_ssi_filter_module.h nginx-1.20.0/src/http/modules/ngx_http_ssl_module.c nginx-1.20.0/src/http/modules/ngx_http_ssl_module.h nginx-1.20.0/src/http/modules/ngx_http_static_module.c nginx-1.20.0/src/http/modules/ngx_http_stub_status_module.c nginx-1.20.0/src/http/modules/ngx_http_sub_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_try_files_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_hash_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_ip_hash_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_keepalive_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_random_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_least_conn_module.c nginx-1.20.0/src/http/modules/ngx_http_upstream_zone_module.c nginx-1.20.0/src/http/modules/ngx_http_userid_filter_module.c nginx-1.20.0/src/http/modules/ngx_http_uwsgi_module.c nginx-1.20.0/src/http/modules/ngx_http_xslt_filter_module.c nginx-1.20.0/src/http/modules/perl/Makefile.PL nginx-1.20.0/src/http/modules/perl/nginx.pm nginx-1.20.0/src/http/modules/perl/nginx.xs nginx-1.20.0/src/http/modules/perl/ngx_http_perl_module.c nginx-1.20.0/src/http/modules/perl/ngx_http_perl_module.h nginx-1.20.0/src/http/modules/perl/typemap nginx-1.20.0/src/event/modules/ nginx-1.20.0/src/event/ngx_event.c nginx-1.20.0/src/event/ngx_event.h nginx-1.20.0/src/event/ngx_event_accept.c nginx-1.20.0/src/event/ngx_event_connect.c nginx-1.20.0/src/event/ngx_event_connect.h nginx-1.20.0/src/event/ngx_event_openssl.c nginx-1.20.0/src/event/ngx_event_openssl.h nginx-1.20.0/src/event/ngx_event_openssl_stapling.c nginx-1.20.0/src/event/ngx_event_pipe.c nginx-1.20.0/src/event/ngx_event_pipe.h nginx-1.20.0/src/event/ngx_event_posted.c nginx-1.20.0/src/event/ngx_event_posted.h nginx-1.20.0/src/event/ngx_event_timer.c nginx-1.20.0/src/event/ngx_event_timer.h nginx-1.20.0/src/event/ngx_event_udp.c nginx-1.20.0/src/event/modules/ngx_devpoll_module.c nginx-1.20.0/src/event/modules/ngx_epoll_module.c nginx-1.20.0/src/event/modules/ngx_eventport_module.c nginx-1.20.0/src/event/modules/ngx_kqueue_module.c nginx-1.20.0/src/event/modules/ngx_poll_module.c nginx-1.20.0/src/event/modules/ngx_select_module.c nginx-1.20.0/src/event/modules/ngx_win32_poll_module.c nginx-1.20.0/src/event/modules/ngx_win32_select_module.c nginx-1.20.0/src/core/nginx.c nginx-1.20.0/src/core/nginx.h nginx-1.20.0/src/core/ngx_array.c nginx-1.20.0/src/core/ngx_array.h nginx-1.20.0/src/core/ngx_buf.c nginx-1.20.0/src/core/ngx_buf.h nginx-1.20.0/src/core/ngx_conf_file.c nginx-1.20.0/src/core/ngx_conf_file.h nginx-1.20.0/src/core/ngx_config.h nginx-1.20.0/src/core/ngx_connection.c nginx-1.20.0/src/core/ngx_connection.h nginx-1.20.0/src/core/ngx_core.h nginx-1.20.0/src/core/ngx_cpuinfo.c nginx-1.20.0/src/core/ngx_crc.h nginx-1.20.0/src/core/ngx_crc32.c nginx-1.20.0/src/core/ngx_crc32.h nginx-1.20.0/src/core/ngx_crypt.c nginx-1.20.0/src/core/ngx_crypt.h nginx-1.20.0/src/core/ngx_cycle.c nginx-1.20.0/src/core/ngx_cycle.h nginx-1.20.0/src/core/ngx_file.c nginx-1.20.0/src/core/ngx_file.h nginx-1.20.0/src/core/ngx_hash.c nginx-1.20.0/src/core/ngx_hash.h nginx-1.20.0/src/core/ngx_inet.c nginx-1.20.0/src/core/ngx_inet.h nginx-1.20.0/src/core/ngx_list.c nginx-1.20.0/src/core/ngx_list.h nginx-1.20.0/src/core/ngx_log.c nginx-1.20.0/src/core/ngx_log.h nginx-1.20.0/src/core/ngx_md5.c nginx-1.20.0/src/core/ngx_md5.h nginx-1.20.0/src/core/ngx_module.c nginx-1.20.0/src/core/ngx_module.h nginx-1.20.0/src/core/ngx_murmurhash.c nginx-1.20.0/src/core/ngx_murmurhash.h nginx-1.20.0/src/core/ngx_open_file_cache.c nginx-1.20.0/src/core/ngx_open_file_cache.h nginx-1.20.0/src/core/ngx_output_chain.c nginx-1.20.0/src/core/ngx_palloc.c nginx-1.20.0/src/core/ngx_palloc.h nginx-1.20.0/src/core/ngx_parse.c nginx-1.20.0/src/core/ngx_parse.h nginx-1.20.0/src/core/ngx_parse_time.c nginx-1.20.0/src/core/ngx_queue.c nginx-1.20.0/src/core/ngx_parse_time.h nginx-1.20.0/src/core/ngx_proxy_protocol.c nginx-1.20.0/src/core/ngx_proxy_protocol.h nginx-1.20.0/src/core/ngx_queue.h nginx-1.20.0/src/core/ngx_radix_tree.c nginx-1.20.0/src/core/ngx_radix_tree.h nginx-1.20.0/src/core/ngx_rbtree.c nginx-1.20.0/src/core/ngx_rbtree.h nginx-1.20.0/src/core/ngx_regex.c nginx-1.20.0/src/core/ngx_regex.h nginx-1.20.0/src/core/ngx_resolver.c nginx-1.20.0/src/core/ngx_resolver.h nginx-1.20.0/src/core/ngx_rwlock.c nginx-1.20.0/src/core/ngx_rwlock.h nginx-1.20.0/src/core/ngx_sha1.c nginx-1.20.0/src/core/ngx_sha1.h nginx-1.20.0/src/core/ngx_shmtx.c nginx-1.20.0/src/core/ngx_shmtx.h nginx-1.20.0/src/core/ngx_slab.c nginx-1.20.0/src/core/ngx_slab.h nginx-1.20.0/src/core/ngx_spinlock.c nginx-1.20.0/src/core/ngx_string.c nginx-1.20.0/src/core/ngx_string.h nginx-1.20.0/src/core/ngx_syslog.c nginx-1.20.0/src/core/ngx_syslog.h nginx-1.20.0/src/core/ngx_thread_pool.c nginx-1.20.0/src/core/ngx_thread_pool.h nginx-1.20.0/src/core/ngx_times.c nginx-1.20.0/src/core/ngx_times.h nginx-1.20.0/contrib/README nginx-1.20.0/contrib/geo2nginx.pl nginx-1.20.0/contrib/unicode2nginx/ nginx-1.20.0/contrib/vim/ nginx-1.20.0/contrib/vim/ftdetect/ nginx-1.20.0/contrib/vim/ftplugin/ nginx-1.20.0/contrib/vim/indent/ nginx-1.20.0/contrib/vim/syntax/ nginx-1.20.0/contrib/vim/syntax/nginx.vim nginx-1.20.0/contrib/vim/indent/nginx.vim nginx-1.20.0/contrib/vim/ftplugin/nginx.vim nginx-1.20.0/contrib/vim/ftdetect/nginx.vim nginx-1.20.0/contrib/unicode2nginx/koi-utf nginx-1.20.0/contrib/unicode2nginx/unicode-to-nginx.pl nginx-1.20.0/contrib/unicode2nginx/win-utf nginx-1.20.0/conf/fastcgi.conf nginx-1.20.0/conf/fastcgi_params nginx-1.20.0/conf/koi-utf nginx-1.20.0/conf/koi-win nginx-1.20.0/conf/mime.types nginx-1.20.0/conf/nginx.conf nginx-1.20.0/conf/scgi_params nginx-1.20.0/conf/uwsgi_params nginx-1.20.0/conf/win-utf nginx-1.20.0/auto/cc/ nginx-1.20.0/auto/define nginx-1.20.0/auto/endianness nginx-1.20.0/auto/feature nginx-1.20.0/auto/have nginx-1.20.0/auto/have_headers nginx-1.20.0/auto/headers nginx-1.20.0/auto/include nginx-1.20.0/auto/init nginx-1.20.0/auto/install nginx-1.20.0/auto/lib/ nginx-1.20.0/auto/make nginx-1.20.0/auto/module nginx-1.20.0/auto/modules nginx-1.20.0/auto/nohave nginx-1.20.0/auto/options nginx-1.20.0/auto/os/ nginx-1.20.0/auto/sources nginx-1.20.0/auto/stubs nginx-1.20.0/auto/summary nginx-1.20.0/auto/threads nginx-1.20.0/auto/types/ nginx-1.20.0/auto/unix nginx-1.20.0/auto/types/sizeof nginx-1.20.0/auto/types/typedef nginx-1.20.0/auto/types/uintptr_t nginx-1.20.0/auto/types/value nginx-1.20.0/auto/os/conf nginx-1.20.0/auto/os/darwin nginx-1.20.0/auto/os/freebsd nginx-1.20.0/auto/os/linux nginx-1.20.0/auto/os/solaris nginx-1.20.0/auto/os/win32 nginx-1.20.0/auto/lib/conf nginx-1.20.0/auto/lib/geoip/ nginx-1.20.0/auto/lib/google-perftools/ nginx-1.20.0/auto/lib/libatomic/ nginx-1.20.0/auto/lib/libgd/ nginx-1.20.0/auto/lib/libxslt/ nginx-1.20.0/auto/lib/make nginx-1.20.0/auto/lib/openssl/ nginx-1.20.0/auto/lib/pcre/ nginx-1.20.0/auto/lib/perl/ nginx-1.20.0/auto/lib/zlib/ nginx-1.20.0/auto/lib/zlib/conf nginx-1.20.0/auto/lib/zlib/make nginx-1.20.0/auto/lib/zlib/makefile.bcc nginx-1.20.0/auto/lib/zlib/makefile.msvc nginx-1.20.0/auto/lib/zlib/makefile.owc nginx-1.20.0/auto/lib/perl/conf nginx-1.20.0/auto/lib/perl/make nginx-1.20.0/auto/lib/pcre/conf nginx-1.20.0/auto/lib/pcre/make nginx-1.20.0/auto/lib/pcre/makefile.bcc nginx-1.20.0/auto/lib/pcre/makefile.msvc nginx-1.20.0/auto/lib/pcre/makefile.owc nginx-1.20.0/auto/lib/openssl/conf nginx-1.20.0/auto/lib/openssl/make nginx-1.20.0/auto/lib/openssl/makefile.bcc nginx-1.20.0/auto/lib/openssl/makefile.msvc nginx-1.20.0/auto/lib/libxslt/conf nginx-1.20.0/auto/lib/libgd/conf nginx-1.20.0/auto/lib/libatomic/conf nginx-1.20.0/auto/lib/libatomic/make nginx-1.20.0/auto/lib/google-perftools/conf nginx-1.20.0/auto/lib/geoip/conf nginx-1.20.0/auto/cc/acc nginx-1.20.0/auto/cc/bcc nginx-1.20.0/auto/cc/ccc nginx-1.20.0/auto/cc/clang nginx-1.20.0/auto/cc/conf nginx-1.20.0/auto/cc/gcc nginx-1.20.0/auto/cc/icc nginx-1.20.0/auto/cc/msvc nginx-1.20.0/auto/cc/name nginx-1.20.0/auto/cc/owc nginx-1.20.0/auto/cc/sunc [root@192 ~]# ls anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music nginx-1.12.0.tar.gz nginx-1.20.0 nginx-1.20.0.tar.gz Pictures Public Templates Videos [root@192 ~]# cd nginx-1.20.0/ [root@192 nginx-1.20.0]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src [root@192 nginx-1.20.0]# ./configure checking for OS + Linux 3.10.0-1160.el7.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) checking for gcc -pipe switch ... found checking for -Wl,-E switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for gcc builtin 64 bit byteswap ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for EPOLLEXCLUSIVE ... not found checking for eventfd() ... found checking for O_PATH ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for prctl(PR_SET_KEEPCAPS) ... found checking for capabilities ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for nobody group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for sched_setaffinity() ... found checking for SO_SETFIB ... not found checking for SO_REUSEPORT ... found checking for SO_ACCEPTFILTER ... not found checking for SO_BINDANY ... not found checking for IP_TRANSPARENT ... found checking for IP_BINDANY ... not found checking for IP_BIND_ADDRESS_NO_PORT ... found checking for IP_RECVDSTADDR ... not found checking for IP_SENDSRCADDR ... not found checking for IP_PKTINFO ... found checking for IPV6_RECVPKTINFO ... found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE ... found checking for TCP_FASTOPEN ... found checking for TCP_INFO ... found checking for accept4() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint32_t ... found checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for AF_INET6 ... found checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for pwritev() ... found checking for strerrordesc_np() ... not found checking for sys_nerr ... found checking for localtime_r() ... found checking for clock_gettime(CLOCK_MONOTONIC) ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for ioctl(FIONREAD) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE library ... found checking for PCRE JIT support ... found checking for zlib library ... found creating objs/Makefile Configuration summary + using system PCRE library + OpenSSL library is not used + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" [root@192 nginx-1.20.0]# make make -f objs/Makefile make[1]: Entering directory `/root/nginx-1.20.0' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/nginx.o \ src/core/nginx.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_log.o \ src/core/ngx_log.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_palloc.o \ src/core/ngx_palloc.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_array.o \ src/core/ngx_array.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_list.o \ src/core/ngx_list.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_hash.o \ src/core/ngx_hash.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_buf.o \ src/core/ngx_buf.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_queue.o \ src/core/ngx_queue.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_output_chain.o \ src/core/ngx_output_chain.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_string.o \ src/core/ngx_string.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_parse.o \ src/core/ngx_parse.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_parse_time.o \ src/core/ngx_parse_time.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_inet.o \ src/core/ngx_inet.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_file.o \ src/core/ngx_file.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_crc32.o \ src/core/ngx_crc32.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_murmurhash.o \ src/core/ngx_murmurhash.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_md5.o \ src/core/ngx_md5.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_sha1.o \ src/core/ngx_sha1.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_rbtree.o \ src/core/ngx_rbtree.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_radix_tree.o \ src/core/ngx_radix_tree.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_slab.o \ src/core/ngx_slab.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_times.o \ src/core/ngx_times.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_shmtx.o \ src/core/ngx_shmtx.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_connection.o \ src/core/ngx_connection.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_cycle.o \ src/core/ngx_cycle.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_spinlock.o \ src/core/ngx_spinlock.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_rwlock.o \ src/core/ngx_rwlock.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_cpuinfo.o \ src/core/ngx_cpuinfo.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_conf_file.o \ src/core/ngx_conf_file.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_module.o \ src/core/ngx_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_resolver.o \ src/core/ngx_resolver.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_open_file_cache.o \ src/core/ngx_open_file_cache.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_crypt.o \ src/core/ngx_crypt.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_proxy_protocol.o \ src/core/ngx_proxy_protocol.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_syslog.o \ src/core/ngx_syslog.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event.o \ src/event/ngx_event.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_timer.o \ src/event/ngx_event_timer.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_posted.o \ src/event/ngx_event_posted.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_accept.o \ src/event/ngx_event_accept.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_udp.o \ src/event/ngx_event_udp.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_connect.o \ src/event/ngx_event_connect.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/ngx_event_pipe.o \ src/event/ngx_event_pipe.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_time.o \ src/os/unix/ngx_time.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_errno.o \ src/os/unix/ngx_errno.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_alloc.o \ src/os/unix/ngx_alloc.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_files.o \ src/os/unix/ngx_files.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_socket.o \ src/os/unix/ngx_socket.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_recv.o \ src/os/unix/ngx_recv.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_readv_chain.o \ src/os/unix/ngx_readv_chain.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_udp_recv.o \ src/os/unix/ngx_udp_recv.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_send.o \ src/os/unix/ngx_send.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_writev_chain.o \ src/os/unix/ngx_writev_chain.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_udp_send.o \ src/os/unix/ngx_udp_send.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_udp_sendmsg_chain.o \ src/os/unix/ngx_udp_sendmsg_chain.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_channel.o \ src/os/unix/ngx_channel.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_shmem.o \ src/os/unix/ngx_shmem.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_process.o \ src/os/unix/ngx_process.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_daemon.o \ src/os/unix/ngx_daemon.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_setaffinity.o \ src/os/unix/ngx_setaffinity.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_setproctitle.o \ src/os/unix/ngx_setproctitle.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_posix_init.o \ src/os/unix/ngx_posix_init.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_user.o \ src/os/unix/ngx_user.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_dlopen.o \ src/os/unix/ngx_dlopen.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_process_cycle.o \ src/os/unix/ngx_process_cycle.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_linux_init.o \ src/os/unix/ngx_linux_init.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/event/modules/ngx_epoll_module.o \ src/event/modules/ngx_epoll_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_linux_sendfile_chain.o \ src/os/unix/ngx_linux_sendfile_chain.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_regex.o \ src/core/ngx_regex.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http.o \ src/http/ngx_http.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_core_module.o \ src/http/ngx_http_core_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_special_response.o \ src/http/ngx_http_special_response.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_request.o \ src/http/ngx_http_request.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_parse.o \ src/http/ngx_http_parse.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_log_module.o \ src/http/modules/ngx_http_log_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_request_body.o \ src/http/ngx_http_request_body.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_variables.o \ src/http/ngx_http_variables.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_script.o \ src/http/ngx_http_script.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_upstream.o \ src/http/ngx_http_upstream.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_upstream_round_robin.o \ src/http/ngx_http_upstream_round_robin.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_file_cache.o \ src/http/ngx_http_file_cache.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_write_filter_module.o \ src/http/ngx_http_write_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_header_filter_module.o \ src/http/ngx_http_header_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_chunked_filter_module.o \ src/http/modules/ngx_http_chunked_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_range_filter_module.o \ src/http/modules/ngx_http_range_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_gzip_filter_module.o \ src/http/modules/ngx_http_gzip_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_postpone_filter_module.o \ src/http/ngx_http_postpone_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_ssi_filter_module.o \ src/http/modules/ngx_http_ssi_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_charset_filter_module.o \ src/http/modules/ngx_http_charset_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_userid_filter_module.o \ src/http/modules/ngx_http_userid_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_headers_filter_module.o \ src/http/modules/ngx_http_headers_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/ngx_http_copy_filter_module.o \ src/http/ngx_http_copy_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_not_modified_filter_module.o \ src/http/modules/ngx_http_not_modified_filter_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_static_module.o \ src/http/modules/ngx_http_static_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_autoindex_module.o \ src/http/modules/ngx_http_autoindex_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_index_module.o \ src/http/modules/ngx_http_index_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_mirror_module.o \ src/http/modules/ngx_http_mirror_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_try_files_module.o \ src/http/modules/ngx_http_try_files_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_auth_basic_module.o \ src/http/modules/ngx_http_auth_basic_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_access_module.o \ src/http/modules/ngx_http_access_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_limit_conn_module.o \ src/http/modules/ngx_http_limit_conn_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_limit_req_module.o \ src/http/modules/ngx_http_limit_req_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_geo_module.o \ src/http/modules/ngx_http_geo_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_map_module.o \ src/http/modules/ngx_http_map_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_split_clients_module.o \ src/http/modules/ngx_http_split_clients_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_referer_module.o \ src/http/modules/ngx_http_referer_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_rewrite_module.o \ src/http/modules/ngx_http_rewrite_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_proxy_module.o \ src/http/modules/ngx_http_proxy_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_fastcgi_module.o \ src/http/modules/ngx_http_fastcgi_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_uwsgi_module.o \ src/http/modules/ngx_http_uwsgi_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_scgi_module.o \ src/http/modules/ngx_http_scgi_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_memcached_module.o \ src/http/modules/ngx_http_memcached_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_empty_gif_module.o \ src/http/modules/ngx_http_empty_gif_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_browser_module.o \ src/http/modules/ngx_http_browser_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_hash_module.o \ src/http/modules/ngx_http_upstream_hash_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \ src/http/modules/ngx_http_upstream_ip_hash_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_least_conn_module.o \ src/http/modules/ngx_http_upstream_least_conn_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_random_module.o \ src/http/modules/ngx_http_upstream_random_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_keepalive_module.o \ src/http/modules/ngx_http_upstream_keepalive_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/src/http/modules/ngx_http_upstream_zone_module.o \ src/http/modules/ngx_http_upstream_zone_module.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/ngx_modules.o \ objs/ngx_modules.c cc -o objs/nginx \ objs/src/core/nginx.o \ objs/src/core/ngx_log.o \ objs/src/core/ngx_palloc.o \ objs/src/core/ngx_array.o \ objs/src/core/ngx_list.o \ objs/src/core/ngx_hash.o \ objs/src/core/ngx_buf.o \ objs/src/core/ngx_queue.o \ objs/src/core/ngx_output_chain.o \ objs/src/core/ngx_string.o \ objs/src/core/ngx_parse.o \ objs/src/core/ngx_parse_time.o \ objs/src/core/ngx_inet.o \ objs/src/core/ngx_file.o \ objs/src/core/ngx_crc32.o \ objs/src/core/ngx_murmurhash.o \ objs/src/core/ngx_md5.o \ objs/src/core/ngx_sha1.o \ objs/src/core/ngx_rbtree.o \ objs/src/core/ngx_radix_tree.o \ objs/src/core/ngx_slab.o \ objs/src/core/ngx_times.o \ objs/src/core/ngx_shmtx.o \ objs/src/core/ngx_connection.o \ objs/src/core/ngx_cycle.o \ objs/src/core/ngx_spinlock.o \ objs/src/core/ngx_rwlock.o \ objs/src/core/ngx_cpuinfo.o \ objs/src/core/ngx_conf_file.o \ objs/src/core/ngx_module.o \ objs/src/core/ngx_resolver.o \ objs/src/core/ngx_open_file_cache.o \ objs/src/core/ngx_crypt.o \ objs/src/core/ngx_proxy_protocol.o \ objs/src/core/ngx_syslog.o \ objs/src/event/ngx_event.o \ objs/src/event/ngx_event_timer.o \ objs/src/event/ngx_event_posted.o \ objs/src/event/ngx_event_accept.o \ objs/src/event/ngx_event_udp.o \ objs/src/event/ngx_event_connect.o \ objs/src/event/ngx_event_pipe.o \ objs/src/os/unix/ngx_time.o \ objs/src/os/unix/ngx_errno.o \ objs/src/os/unix/ngx_alloc.o \ objs/src/os/unix/ngx_files.o \ objs/src/os/unix/ngx_socket.o \ objs/src/os/unix/ngx_recv.o \ objs/src/os/unix/ngx_readv_chain.o \ objs/src/os/unix/ngx_udp_recv.o \ objs/src/os/unix/ngx_send.o \ objs/src/os/unix/ngx_writev_chain.o \ objs/src/os/unix/ngx_udp_send.o \ objs/src/os/unix/ngx_udp_sendmsg_chain.o \ objs/src/os/unix/ngx_channel.o \ objs/src/os/unix/ngx_shmem.o \ objs/src/os/unix/ngx_process.o \ objs/src/os/unix/ngx_daemon.o \ objs/src/os/unix/ngx_setaffinity.o \ objs/src/os/unix/ngx_setproctitle.o \ objs/src/os/unix/ngx_posix_init.o \ objs/src/os/unix/ngx_user.o \ objs/src/os/unix/ngx_dlopen.o \ objs/src/os/unix/ngx_process_cycle.o \ objs/src/os/unix/ngx_linux_init.o \ objs/src/event/modules/ngx_epoll_module.o \ objs/src/os/unix/ngx_linux_sendfile_chain.o \ objs/src/core/ngx_regex.o \ objs/src/http/ngx_http.o \ objs/src/http/ngx_http_core_module.o \ objs/src/http/ngx_http_special_response.o \ objs/src/http/ngx_http_request.o \ objs/src/http/ngx_http_parse.o \ objs/src/http/modules/ngx_http_log_module.o \ objs/src/http/ngx_http_request_body.o \ objs/src/http/ngx_http_variables.o \ objs/src/http/ngx_http_script.o \ objs/src/http/ngx_http_upstream.o \ objs/src/http/ngx_http_upstream_round_robin.o \ objs/src/http/ngx_http_file_cache.o \ objs/src/http/ngx_http_write_filter_module.o \ objs/src/http/ngx_http_header_filter_module.o \ objs/src/http/modules/ngx_http_chunked_filter_module.o \ objs/src/http/modules/ngx_http_range_filter_module.o \ objs/src/http/modules/ngx_http_gzip_filter_module.o \ objs/src/http/ngx_http_postpone_filter_module.o \ objs/src/http/modules/ngx_http_ssi_filter_module.o \ objs/src/http/modules/ngx_http_charset_filter_module.o \ objs/src/http/modules/ngx_http_userid_filter_module.o \ objs/src/http/modules/ngx_http_headers_filter_module.o \ objs/src/http/ngx_http_copy_filter_module.o \ objs/src/http/modules/ngx_http_not_modified_filter_module.o \ objs/src/http/modules/ngx_http_static_module.o \ objs/src/http/modules/ngx_http_autoindex_module.o \ objs/src/http/modules/ngx_http_index_module.o \ objs/src/http/modules/ngx_http_mirror_module.o \ objs/src/http/modules/ngx_http_try_files_module.o \ objs/src/http/modules/ngx_http_auth_basic_module.o \ objs/src/http/modules/ngx_http_access_module.o \ objs/src/http/modules/ngx_http_limit_conn_module.o \ objs/src/http/modules/ngx_http_limit_req_module.o \ objs/src/http/modules/ngx_http_geo_module.o \ objs/src/http/modules/ngx_http_map_module.o \ objs/src/http/modules/ngx_http_split_clients_module.o \ objs/src/http/modules/ngx_http_referer_module.o \ objs/src/http/modules/ngx_http_rewrite_module.o \ objs/src/http/modules/ngx_http_proxy_module.o \ objs/src/http/modules/ngx_http_fastcgi_module.o \ objs/src/http/modules/ngx_http_uwsgi_module.o \ objs/src/http/modules/ngx_http_scgi_module.o \ objs/src/http/modules/ngx_http_memcached_module.o \ objs/src/http/modules/ngx_http_empty_gif_module.o \ objs/src/http/modules/ngx_http_browser_module.o \ objs/src/http/modules/ngx_http_upstream_hash_module.o \ objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \ objs/src/http/modules/ngx_http_upstream_least_conn_module.o \ objs/src/http/modules/ngx_http_upstream_random_module.o \ objs/src/http/modules/ngx_http_upstream_keepalive_module.o \ objs/src/http/modules/ngx_http_upstream_zone_module.o \ objs/ngx_modules.o \ -ldl -lpthread -lcrypt -lpcre -lz \ -Wl,-E sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/root/nginx-1.20.0' [root@192 nginx-1.20.0]# make install make -f objs/Makefile install make[1]: Entering directory `/root/nginx-1.20.0' test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx' test -d '/usr/local/nginx/sbin' \ || mkdir -p '/usr/local/nginx/sbin' test ! -f '/usr/local/nginx/sbin/nginx' \ || mv '/usr/local/nginx/sbin/nginx' \ '/usr/local/nginx/sbin/nginx.old' cp objs/nginx '/usr/local/nginx/sbin/nginx' test -d '/usr/local/nginx/conf' \ || mkdir -p '/usr/local/nginx/conf' cp conf/koi-win '/usr/local/nginx/conf' cp conf/koi-utf '/usr/local/nginx/conf' cp conf/win-utf '/usr/local/nginx/conf' test -f '/usr/local/nginx/conf/mime.types' \ || cp conf/mime.types '/usr/local/nginx/conf' cp conf/mime.types '/usr/local/nginx/conf/mime.types.default' test -f '/usr/local/nginx/conf/fastcgi_params' \ || cp conf/fastcgi_params '/usr/local/nginx/conf' cp conf/fastcgi_params \ '/usr/local/nginx/conf/fastcgi_params.default' test -f '/usr/local/nginx/conf/fastcgi.conf' \ || cp conf/fastcgi.conf '/usr/local/nginx/conf' cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default' test -f '/usr/local/nginx/conf/uwsgi_params' \ || cp conf/uwsgi_params '/usr/local/nginx/conf' cp conf/uwsgi_params \ '/usr/local/nginx/conf/uwsgi_params.default' test -f '/usr/local/nginx/conf/scgi_params' \ || cp conf/scgi_params '/usr/local/nginx/conf' cp conf/scgi_params \ '/usr/local/nginx/conf/scgi_params.default' test -f '/usr/local/nginx/conf/nginx.conf' \ || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf' cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' test -d '/usr/local/nginx/html' \ || cp -R html '/usr/local/nginx' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' make[1]: Leaving directory `/root/nginx-1.20.0' [root@192 nginx-1.20.0]# whereis nginx nginx: /usr/local/nginx [root@192 nginx-1.20.0]# cd /usr/local/nginx/sbin/ [root@192 sbin]# ls nginx [root@192 sbin]# ./nginx [root@192 sbin]# yum install net-tools Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Package net-tools-2.0-0.25.20131004git.el7.x86_64 already installed and latest version Nothing to do [root@192 sbin]# ps aux|grep nginx root 7602 0.0 0.0 20580 620 ? Ss 14:49 0:00 nginx: master process ./nginx nobody 7603 0.0 0.0 23108 1376 ? S 14:49 0:00 nginx: worker process root 7612 0.0 0.0 112812 972 pts/0 S+ 14:49 0:00 grep --color=auto nginx [root@192 sbin]#
2-8 Nginx的目录和配置语法_Nginx安装目录 (10:01)
[root@192 nginx]# rpm -ql nginx--------------etc 主要存放一些核心的配置文件/etc/logrotate.d/nginx #Nginx 日志轮转 用于 logrotat服务的日志切割。如:按天 /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/fastcgi_params /etc/nginx/mime.types /etc/nginx/modules /etc/nginx/nginx.conf /etc/nginx/scgi_params /etc/nginx/uwsgi_params--------------usr /usr/lib/systemd/system/nginx-debug.service /usr/lib/systemd/system/nginx.service /usr/lib64/nginx /usr/lib64/nginx/modules /usr/libexec/initscripts/legacy-actions/nginx /usr/libexec/initscripts/legacy-actions/nginx/check-reload /usr/libexec/initscripts/legacy-actions/nginx/upgrade /usr/sbin/nginx /usr/sbin/nginx-debug /usr/share/doc/nginx-1.20.1 /usr/share/doc/nginx-1.20.1/COPYRIGHT /usr/share/man/man8/nginx.8.gz /usr/share/nginx /usr/share/nginx/html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html--------------usr /var/cache/nginx /var/log/nginx [root@192 nginx]#
2-9 Nginx的目录和配置语法_Nginx编译配置参数 (06:03)
[root@192 nginx]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments:
--prefix=/etc/nginx--sbin-path=/usr/sbin/nginx--modules-path=/usr/lib64/nginx/modules--conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx--group=nginx--with-compat
--with-file-aio--with-threads
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-mail
--with-mail_ssl_module
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic –fPIC'
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' [root@192 nginx]#
2-10 Nginx的目录和配置语法_默认配置语法 (11:33)
[root@192 client_temp]# cat /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } [root@192 client_temp]#
注:nginx 刚安装的时候,有2个默认加载的配置文件:
1: /etc/nginx/nginx.conf
2: /etc/nginx/conf.d/*.conf;
而在该目录下 初始化时候只有 default.conf 这个配置文件
user: 设置nginx服务的系统使用用户 。设置nginx worker_processes工作进程的用户信息
worker_processes: 工作进程数
这个worker process这一块呢其实是跟我们nginx的一个多work就是多进程的方式是有关系的。
那么我们都知道这个io复用,那么在worker process这一块呢其实是跟我们nginx的一个多work就是多进程的方式是有关系的。我们会启用多个这个进程来进行增大它的连接数的并发处理,那么这个的数量一般和我们的cpu保持一致就可以了。
我们如果是八核心的cpu,那么这个地方呢设置八个。
那么过多的呢其实对系统呢不会有太大的好处,也不会太大的坏处,但是嗯吃的过多据说会引起一些额外的这个切换所造成的一些性能的损耗,但是这个没有经过证实,所以我们只要设置成跟我的cpu个数保持一致就可以。
error_log:nginx的错误日志
这个地方是定义的一个我的错误日志,也就是n这个词这个服务的错误日志后面加的是一个路径。
pid:nginx服务启动的是pid
定义一个位置,这个存放nginx pid的一个位置。
events: 事件模块
另外一个模块呢就是events模块,这个里面呢最常用到的一个就是worker connection。
worker_connections:每个进程允许最大连接数
这个地方的worker_connection和上面这个worker_processes其实一样的,上面定义的是我们有多少个进程,那么这个地方定义的是我一个进程允许护理的最大连接数,当然我们处理的人员数最多,越多越好。
这个地方我们在继续实际企业的进行nginx优化的时候呢,这个是必须要去调节的,那么可以调到6535,也就是最大的这个连接数、端口的配置的这个数量,那么一般调节到。
一万个左右,就可以满足大部分的企业的基本要求了。
所以同学们这个参数呢是需要进行优化的。
use:工作进程数
当然我们在nfc优化这一章,呃实际企业优化这章会为大家在系统的来进行相应的一些讲解。
另外一个就是use 这个呢就是我们来设置nginx使用那种内核模型,在linux里面常用的是select
Httpp:
nginx http 协议:
http这一个大的模块了,按照层级来划分的话,我们会看到http是。
另外一次,所有的http我都可以包含多个这个http的服务,那么我们可以理解成我们访问一个网站都是用的http的这个协议,比如说http://www.baidu.com、http://www.nginx.org,我们都是有http,所以http是放在最外面这一层,那么它可不可以有多个服务?
可以,我们可以配置m这个站点,也可以配置m个c这个站点 ,也可以配置百度这个站点,只要是一个一个的server来进行组成就可以了。
那么一个server配置一个虚拟或者是一个独立的站点,那么在每一个server里面配置它当前server的属性,那么在这个server里面我们主要是配置。
监听哪个端口 如:80端口
server name是什么? 如: localhost(默认) 如果有虚拟主机、有自己独立域名的同学,就把主机名或者对外的域名填入到server内里面去。
location是server下面的一个模块,它主要是控制着我们的每一层的路径的访问,比如说我们默认访问的是 www.im.com首页,那么首页就是加一个杠,那么它的控制的就是我的首页,/www.im.com
如果是访问我的首页这一层的话,我是在哪个路径下面,那么这个杠啊我们后续。
比如说我们子目录的情况下面,那么都可以通过默认的这个杠一次性就把它涵盖到了。所以这一块就是配置我们默认访问的路径所定义的一些位置
error_page是我的错误页面。
那么当我们访问不到页面,或者是服务端出现500、502、503、504的返回状态码时候,我们统一定义一个错误页面返回给用户,这样的话对用户来说一个方面非常友好,另外一个方面也能给用户说明这个目前的一些情况,所以我们会定义一个自己的错误页面,这个页面里面会有错误页面位置,那么这个意思就是说把所有返回如果是错误状态码是500、502、503、504的,它会统一定位递到一个请求路径下面去,那么这个路径会匹配的下一个location,那么下一个location里面会有一个root。
root就是我们这个页面所存放在系统的这个目录的哪个路径下面,也就是50X列表存放在这个路径下面。
那么一个http可以允许有多个server,一个server会出现多个location。
我们对不同的这个路径进行对应的配置,就是通过整个这么一个关系来进行每一个模块的配置的。
那么值得一提的是,在nginx里面,我们对于不同的这个模块。它支持不同的这个层级关系,有的是支持location这一集,有的是支持server这集,有的是location server这集都支持。
[root@192 nginx]# pwd /etc/nginx [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# cat nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; #定义日志类型 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; #nginx 实现加载了nginx.conf 文件后,再加载/etc/nginx/conf.d/ 文件下的所有其他的配置文件 } [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# cd conf.d/ [root@192 conf.d]# ls default.conf [root@192 conf.d]# cat default.conf server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } [root@192 conf.d]#
2-11 Nginx的目录和配置语法_默认配置与默认站点启动 (07:58)
[root@192 nginx]# pwd /etc/nginx [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# cat nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; #设置使用context的配置文件 default_type application/octet-stream; #定义日志类型 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #默认是打开的 #tcp_nopush on; keepalive_timeout 65; #设置客户端 与服务器的超时时间 65 表示超时时间为65秒 #gzip on; include /etc/nginx/conf.d/*.conf; #子配置文件:nginx 实现加载了nginx.conf 文件后,再加载/etc/nginx/conf.d/ 文件下的所有其他的配置文件 } [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# cd conf.d/ [root@192 conf.d]# ls default.conf [root@192 conf.d]# cat default.conf#该配置文件配置的主要是一个子的server服务 server { listen 80; #指 这个server监听的端口是80端口,这个端口号可以改为其他端口号 server_name localhost; #指这个server的一个服务名称。用域名的方式访问的一个域名地址:如 localhost可以更改为:baidu.com 。对于不同的服务可以用服务名称进行区别,也可以使用端口号进行区别 #access_log /var/log/nginx/host.access.log main; #一个服务塞rver里 可以 有多个location. location / { # location / 的设置是表示该服务里的location如果没有配置其他location ,则该路径表示默认的路径。访问所有的这个首页路径或者子路径,都进入到这个location 里面去进行访问 root /usr/share/nginx/html; #root 是我这个location 那里面所返回的这个页面的路径。也就是存放首页的路径 index index.html index.htm; #index 定义首页默认是访问的哪个页面。如果首页访问的是index.html,则默认为index.html 。如果index.html在该路径下无法找到的话,则会去找index.htm } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; #增加1个404 的返回错误信息展示路径内容 location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } [root@192 conf.d]#
---------查看nginx 默认配置文件里设置的 server里的默认location里的 root根目录下 html路径文件信息-----------------------------
[root@192 ~]# cd /etc/nginx/ [root@192 nginx]# ls conf.d mime.types nginx.conf uwsgi_params fastcgi_params modules scgi_params [root@192 nginx]# clear [root@192 nginx]# ls conf.d mime.types nginx.conf uwsgi_params fastcgi_params modules scgi_params [root@192 nginx]# cd conf.d/ [root@192 conf.d]# ls default.conf [root@192 conf.d]# cat default.conf server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } [root@192 conf.d]# cat /usr/share/nginx/html/ cat: /usr/share/nginx/html/: Is a directory [root@192 conf.d]# cat /usr/share/nginx/html/index.html <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx! Alan@123.qq.com </h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> [root@192 conf.d]#[root@192 conf.d]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:cc:38:6c brd ff:ff:ff:ff:ff:ff inet 192.168.0.21/24 brd 192.168.0.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::8837:7fda:866c:e3c1/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:78:65:11 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:78:65:11 brd ff:ff:ff:ff:ff:ff [root@192 conf.d]#
"default.conf" 44L, 1076C written [root@192 conf.d]# cat /usr/share/nginx/html/50x.html <!DOCTYPE html> <html> <head> <title>Error</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>An error occurred.</h1> <p>Sorry, the page you are looking for is currently unavailable.<br/> Please try again later.</p> <p>If you are the system administrator of this resource then you should check the error log for details.</p> <p><em>Faithfully yours, nginx.</em></p> </body> </html> [root@192 conf.d]# vi /usr/share/nginx/html/50x.html
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>An error occurred.</h1><h1><font color="#FF0000">This is a error pags info to view.!</font> </h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
<p>If you are the system administrator of this resource then you should check
the error log for details.</p>
<p><em>Faithfully yours, nginx.</em></p>
</body>
</html>
重启前界面访问效果:
重启nginx服务:
Last login: Sun Nov 7 15:43:23 2021 from 192.168.0.10 [root@192 ~]# systemctl restart nginx.service [root@192 ~]#
2-12 HTTP请求 (04:58)
httpp请求。
nginx作为web server和http代理. 处理的就是http的请求,那么http请求也是建立在tcp基础之上。
那么每一个http请求主要包括了两个,一个是客户端发起一次request请求给服务端,那服务端进行一个response的响应,每一次request和response都会发送对应的http报文,而每一个报文分别是不一样的。
request主要包括请求行、请求同步和请求数据。response主要包括状态啊、消息、放松的响应。
使用Curl在linux环境上模拟 http请求信息:
-----linux安装 curl
View Code[root@192 ~]# yum -y install curl Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * centos-sclo-rh: mirrors.ustc.edu.cn * centos-sclo-sclo: ftp.sjtu.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package curl.x86_64 0:7.29.0-59.el7 will be updated ---> Package curl.x86_64 0:7.29.0-59.el7_9.1 will be an update --> Processing Dependency: libcurl = 7.29.0-59.el7_9.1 for package: curl-7.29.0-59.el7_9.1.x86_64 --> Running transaction check ---> Package libcurl.x86_64 0:7.29.0-59.el7 will be updated ---> Package libcurl.x86_64 0:7.29.0-59.el7_9.1 will be an update --> Finished Dependency Resolution Dependencies Resolved ========================================================================= Package Arch Version Repository Size ========================================================================= Updating: curl x86_64 7.29.0-59.el7_9.1 updates 271 k Updating for dependencies: libcurl x86_64 7.29.0-59.el7_9.1 updates 223 k Transaction Summary ========================================================================= Upgrade 1 Package (+1 Dependent package) Total size: 494 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libcurl-7.29.0-59.el7_9.1.x86_64 1/4 Updating : curl-7.29.0-59.el7_9.1.x86_64 2/4 Cleanup : curl-7.29.0-59.el7.x86_64 3/4 Cleanup : libcurl-7.29.0-59.el7.x86_64 4/4 Verifying : curl-7.29.0-59.el7_9.1.x86_64 1/4 Verifying : libcurl-7.29.0-59.el7_9.1.x86_64 2/4 Verifying : libcurl-7.29.0-59.el7.x86_64 3/4 Verifying : curl-7.29.0-59.el7.x86_64 4/4 Updated: curl.x86_64 0:7.29.0-59.el7_9.1 Dependency Updated: libcurl.x86_64 0:7.29.0-59.el7_9.1 Complete! [root@192 ~]#模拟 请求:
[root@192 ~]# curl -v http://www.baidu.com > /dev/curlTxt.txt % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to www.baidu.com port 80 (#0) * Trying 14.215.177.38... * Connected to www.baidu.com (14.215.177.38) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.baidu.com > Accept: */* > < HTTP/1.1 200 OK < Accept-Ranges: bytes < Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform < Connection: keep-alive < Content-Length: 2381 < Content-Type: text/html < Date: Sun, 07 Nov 2021 08:35:12 GMT < Etag: "588604dc-94d" < Last-Modified: Mon, 23 Jan 2017 13:27:56 GMT < Pragma: no-cache < Server: bfe/1.0.8.18 < Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/ < { [data not shown] 100 2381 100 2381 0 0 46321 0 --:--:-- --:--:-- --:--:-- 46686 * Connection #0 to host www.baidu.com left intact [root@192 ~]#从报文中显示的内容来看:
发起的request 请求内容:
> GET / HTTP/1.1 #请求方式:get、post http/1.1 指请求的协议 > User-Agent: curl/7.29.0 #请求头的内容 > Host: www.baidu.com > Accept: */* >
服务端返回的response 响应内容:
< HTTP/1.1 200 OK #响应状态:200 是http协议响应 最常见的状态码,表示服务端正常响应
#响应头文件内容 < Accept-Ranges: bytes < Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform < Connection: keep-alive < Content-Length: 2381 < Content-Type: text/html < Date: Sun, 07 Nov 2021 08:35:12 GMT < Etag: "588604dc-94d" < Last-Modified: Mon, 23 Jan 2017 13:27:56 GMT < Pragma: no-cache < Server: bfe/1.0.8.18 < Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/ <
2-13 Nginx虚拟主机及实现方式 (09:35)
2-14 Nginx虚拟主机单网卡多IP配置演示 (15:41)
2-15 Nginx虚拟主机基于多端口的配置演示 (08:24)
2-16 Nginx虚拟主机基于host域名的配置演示 (09:50)
2-17 Nginx日志_log_format1 ____---->nginx的变量参数 详解
日志呢主要包括了error.log和access_log。
error.log主要记录n这个词的处理http请求的错误的状态,以及nginx本身服务的运行的错误状态。 按照不同的级别记录到errorlog里面。 相对于配置来说是非常简单的。
access_log 进入到nginx的每一次http请求的访问状态。 主要用于我们去分析每一次访问的请求和客户的进行交互,以及对行为的进行一些分析。在企业的实际应用里面的用的比较多的。
那么nginx是怎么实现的呢?
主要依赖于一个log_formate的配置。
那么nginx log里面记录了很多的信息,其每一个信息可以理解成都是nginx里面的对应的一个变量。 log_format把这些变量组织到一起,写入到 access_log 里。
log_formate 配置语法:
首先第一行呢就是log_format的配置语法,
其默认语法如上图显示: Default……
最后context主要是说明 对于log_format只能配置在http这个模块下面,也就是必须得配置在http的大的模块下面。
对于log_format的配置位置是有约束的。Syntax: log_formate name [escape=default|json]string …….
------- ------------- ---------------------- -------------------------------------------------
关键字 格式名字(可以自定义, 所有的字符串或者是变量
类似变量名)
那么我们有讲过access_log是把nginx.log相关的变量组织到一起,然后呢写入到access.log里面。
[root@192 ~]# pwd /root [root@192 ~]# cd /etc/nginx/ [root@192 nginx]# ls conf.d mime.types nginx.conf uwsgi_params fastcgi_params modules scgi_params [root@192 nginx]# cat nginx.conf user nginx; worker_processes auto; #配置nginx错误日志的地方: 记录了nginx错误日志的位置 warn 表示错误日志的级别为:warning(警告) notice、notice # 日志内容: 日期 、错误日志级别、对应错误代码、错误发生的行为描述、用户请求的信息、用户的IP信息、 error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; #log_format 的name名称为:main #nginx 变量: $remote_addr : #nginx 变量: $remote_user #nginx 变量: [$time_local] #nginx 变量: $request #nginx 变量: $status #nginx 变量: $body_bytes_sent #nginx 变量: $http_referer #nginx 变量: $http_user_agent #nginx 变量: $http_x_forwarded_for log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; # access_log access_log文件存放路径 记录nginx log_format的name信息。 access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } [root@192 nginx]#Nginx 变量
http 请求变量:
arg_PARAMETER: 参数请求输出格式:(arg_参数名形式)
http_HEADER: http支持request请求里的 header内容输出
sent_http_HEADER: 服务端返回给请求端的response里的header内容信息
·
---示例:-----------------------------------------------------------------------------------------------------------------------
如果把一个请求的头文件里的User-Agent信息对应日志的操作方式;
1:查询出请求日志的操作方式:[root@192 nginx]# curl -v www.baidu.com/ > /dev/logTxt.txt
请求日志的头文件信息:
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.baidu.com
> Accept: */*
>
View Code[root@192 nginx]# curl -v www.baidu.com/ > /dev/logTxt.txt % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to www.baidu.com port 80 (#0) * Trying 14.215.177.39... * Connected to www.baidu.com (14.215.177.39) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.baidu.com > Accept: */* > < HTTP/1.1 200 OK < Accept-Ranges: bytes < Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform < Connection: keep-alive < Content-Length: 2381 < Content-Type: text/html < Date: Sun, 07 Nov 2021 14:32:56 GMT < Etag: "588604dd-94d" < Last-Modified: Mon, 23 Jan 2017 13:27:57 GMT < Pragma: no-cache < Server: bfe/1.0.8.18 < Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/ < { [data not shown] 100 2381 100 2381 0 0 42453 0 --:--:-- --:--:-- --:--:-- 43290 * Connection #0 to host www.baidu.com left intact [root@192 nginx]#2:编辑nginx的 nginx.conf文件内容信息:
View Code[root@192 nginx]# vim /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; #'$http_user_agent' '$remote 之间要 以空格隔开。增加的参数要以$符号开头,且其变量名必须 要小写。原变量User-Agent必须 要以 http_user_agent的格式书写 log_format main '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } ~ ~ ~ ~ ~ "nginx.conf" 32L, 669C written #检查nginx配置文件内容是否配置正确 [root@192 nginx]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@192 nginx]# nginx -t -c /etc/nginx/nginx.conf # nginx -c 对配置文件内容进行一次全面性的检查 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful #nginx 配置文件重新加载并做检查 [root@192 nginx]# nginx -s reload -c /etc/nginx/nginx.conf #检查nginx在重新加载配置后的进程信息情况 [root@192 nginx]# ps -aux |grep nginx root 4335 0.0 0.0 46636 1940 ? Ss 16:24 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 8157 0.0 0.0 49124 2084 ? S 22:47 0:00 nginx: worker process nginx 8158 0.0 0.0 49124 2108 ? S 22:47 0:00 nginx: worker process nginx 8159 0.0 0.0 49124 2124 ? S 22:47 0:00 nginx: worker process nginx 8160 0.0 0.0 49124 2112 ? S 22:47 0:00 nginx: worker process root 8172 0.0 0.0 112812 972 pts/2 S+ 22:48 0:00 grep --color=auto nginx #重新访问本地请求服务: [root@192 nginx]# curl http://127.0.0.1 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx! Alan@123.qq.com </h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> [root@192 nginx]# ls conf.d mime.types nginx.conf uwsgi_params fastcgi_params modules scgi_params #再一次访问本地请求服务: [root@192 nginx]# curl http://127.0.0.1 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx! Alan@123.qq.com </h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> #查看请求日志信息: [root@192 nginx]# tail -n 200 /var/log/nginx/access.log 192.168.0.10 - - [07/Nov/2021:15:54:24 +0800] "GET / HTTP/1.1" 200 630 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:15:54:24 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.0.21/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:15:58:23 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:11:27 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:11:31 +0800] "GET /sdfasfda HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:24 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:26 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:27 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:28 +0800] "GET /asdfasdfasdfa HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:36 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:36 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:15:40 +0800] "GET /asdfasdfasdfa.html HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:17:36 +0800] "GET /asdfasdfasdfa.html HTTP/1.1" 404 494 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:22:06 +0800] "GET /asdfasdfasdfa.html HTTP/1.1" 404 494 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" 192.168.0.10 - - [07/Nov/2021:16:24:55 +0800] "GET /asdfasdfasdfa.html HTTP/1.1" 404 568 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400" "-" curl/7.29.0127.0.0.1 - - [07/Nov/2021:22:49:57 +0800] "GET / HTTP/1.1" 200 630 "-" "curl/7.29.0" "-" # 这是修改了 nginx.conf配置日志输出信息格式的内容 curl/7.29.0127.0.0.1 - - [07/Nov/2021:22:50:16 +0800] "GET / HTTP/1.1" 200 630 "-" "curl/7.29.0" "-" [root@192 nginx]#
curl/7.29.0 127.0.0.1 - - [07/Nov/2021:22:50:16 +0800] "GET / HTTP/1.1" 200 630 "-" "curl/7.29.0" "-" 在编辑了 nginx.conf配置文件里的日志输出arg_parameter的参数信息过后,重新加载了nginx配置文件后,做访问请求后打印在日志里的内容信息;“curl/7.29.0”这就是htpp请求所打印出来的日志信息
内置变量:
Nginx内置变量:(详情见:http://nginx.org/en/docs/syslog.html)
access_log的内置变量说明文档:http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
查看是有变量信息:http://nginx.org/en/docs/http/ngx_http_log_module.html#var_status
nginx的变量参数 详解 $args #请求中的参数值 $query_string #同 $args $arg_NAME #GET请求中NAME的值 $is_args #如果请求中有参数,值为"?",否则为空字符串 $uri #请求中的当前URI(不带请求参数,参数位于$args),可以不同于浏览器传递的$request_uri的值, 它可以通过内部重定向,或者使用index指令进行修改,$uri不包含主机名,如"/foo/bar.html"。 $document_uri #同 $uri.当前请求中不包含指令的URI,如www.123.com/1.php?a=1&b=2的$document_uri就是1.php,不包含后面的参数。 $document_root #当前请求的文档根目录或别名.nginx虚拟主机配置文件中的root参数对应的值 $host #优先级:HTTP请求行的主机名>"HOST"请求头字段>符合请求的服务器名.请求中的主机头字段,如果请求中的主机头不可用,则为服务器处理请求的服务器名称 $hostname #主机名 $https #如果开启了SSL安全模式,值为"on",否则为空字符串。 $binary_remote_addr #客户端地址的二进制形式,固定长度为4个字节 $body_bytes_sent #传输给客户端的字节数,响应头不计算在内;这个变量和Apache的mod_log_config模块中的"%B"参数保持兼容 $bytes_sent #传输给客户端的字节数 $connection #TCP连接的序列号 $connection_requests #TCP连接当前的请求数量 $content_length #"Content-Length" 请求头字段 $content_type #"Content-Type" 请求头字段 $cookie_name #cookie名称 $limit_rate #用于设置响应的速度限制.如果nginx服务器使用limit_rate配置了显示网络速率,则会显示,如果没有设置,则显示为0. $msec #当前的Unix时间戳 $nginx_version #nginx版本 $pid #工作进程的PID $pipe #如果请求来自管道通信,值为"p",否则为"." $proxy_protocol_addr #获取代理访问服务器的客户端地址,如果是直接访问,该值为空字符串 $realpath_root #当前请求的文档根目录或别名的真实路径,会将所有符号连接转换为真实路径 $remote_addr #客户端地址.客户端的公网ip $remote_port #客户端端口 $remote_user #用于HTTP基础认证服务的用户名.如果nginx有配置认证,该变量代表客户端认证的用户名 $request #代表客户端的请求地址 $request_body #客户端的请求主体:此变量可在location中使用,将请求主体通过proxy_pass,fastcgi_pass,uwsgi_pass和scgi_pass传递给下一级的代理服务器 $request_body_file #将客户端请求主体保存在临时文件中。文件处理结束后,此文件需删除。如果需要之一开启此功能,需要设置client_body_in_file_only。 如果将次文件传递给后端的代理服务器,需要禁用request body, 即设置proxy_pass_request_body off,fastcgi_pass_request_body off,uwsgi_pass_request_body off,or scgi_pass_request_body off $request_completion #如果请求成功,值为"OK",如果请求未完成或者请求不是一个范围请求的最后一部分,则为空 $request_filename #当前连接请求的文件路径,由root或alias指令与URI请求生成 $request_length #请求的长度 (包括请求的地址,http请求头和请求主体) $request_method #HTTP请求方法,通常为"GET"或"POST" $request_time #处理客户端请求使用的时间,单位为秒,精度毫秒; 从读入客户端的第一个字节开始,直到把最后一个字符发送给客户端后进行日志写入为止。 $request_uri 请求的连接,包括$document_uri和$args.#这个变量等于包含一些客户端请求参数的原始URI,它无法修改,请查看$uri更改或重写URI,不包含主机名,例如:"/cnphp/test.php?arg=freemouse" $scheme #请求使用的Web协议,"http" 或 "https" $server_addr #服务器端地址,需要注意的是:为了避免访问linux系统内核,应将ip地址提前设置在配置文件中 $server_name #服务器名 $server_port #服务器端口 $server_protocol #服务器的HTTP版本,通常为 "HTTP/1.0" 或 "HTTP/1.1" $status #HTTP响应代码 $time_iso8601 #服务器时间的ISO 8610格式 $time_local #服务器时间(LOG Format 格式) $cookie_NAME #客户端请求Header头中的cookie变量,前缀"$cookie_"加上cookie名称的变量,该变量的值即为cookie名称的值 $http_NAME #匹配任意请求头字段;变量名中的后半部分NAME可以替换成任意请求头字段, 如在配置文件中需要获取http请求头:"Accept-Language",$http_accept_language即可 $http_cookie $http_host #请求地址,即浏览器中你输入的地址(IP或域名) $http_referer #url跳转来源,用来记录从那个页面链接访问过来的.客户端请求时的referer,通俗讲就是该请求时通过哪个连接跳进来的,也就是我们在百度搜一个关键字,然后可以点击条目跳进一个网站,点击的那个链接就是你的referer,用curl -e可以指定。 $http_user_agent #用户终端浏览器等信息 $http_x_forwarded_for
View CodeHTTP X-Forwarded-For 介绍 分类 编程技术 X-Forwarded-For 是一个 HTTP 扩展头部。HTTP/1.1(RFC 2616)协议并没有对它的定义,它最开始是由 Squid 这个缓存代理软件引入,用来表示 HTTP 请求端真实 IP。如今它已经成为事实上的标准,被各大 HTTP 代理、负载均衡等转发服务广泛使用,并被写入 RFC 7239(Forwarded HTTP Extension)标准之中。 X-Forwarded-For 请求头格式非常简单,就这样: X-Forwarded-For: client, proxy1, proxy2 可以看到,XFF 的内容由「英文逗号 + 空格」隔开的多个部分组成,最开始的是离服务端最远的设备 IP,然后是每一级代理设备的 IP。 如果一个 HTTP 请求到达服务器之前,经过了三个代理 Proxy1、Proxy2、Proxy3,IP 分别为 IP1、IP2、IP3,用户真实 IP 为 IP0,那么按照 XFF 标准,服务端最终会收到以下信息: X-Forwarded-For: IP0, IP1, IP2 Proxy3 直连服务器,它会给 XFF 追加 IP2,表示它是在帮 Proxy2 转发请求。列表中并没有 IP3,IP3 可以在服务端通过 Remote Address 字段获得。我们知道 HTTP 连接基于 TCP 连接,HTTP 协议中没有 IP 的概念,Remote Address 来自 TCP 连接,表示与服务端建立 TCP 连接的设备 IP,在这个例子里就是 IP3。 Remote Address 无法伪造,因为建立 TCP 连接需要三次握手,如果伪造了源 IP,无法建立 TCP 连接,更不会有后面的 HTTP 请求。不同语言获取 Remote Address 的方式不一样,例如 php 是 $_SERVER["REMOTE_ADDR"],Node.js 是 req.connection.remoteAddress,但原理都一样。 问题 有了上面的背景知识,开始说问题。我用 Node.js 写了一个最简单的 Web Server 用于测试。HTTP 协议跟语言无关,这里用 Node.js 只是为了方便演示,换成任何其他语言都可以得到相同结论。另外本文用 Nginx 也是一样的道理,如果有兴趣,换成 Apache 或其他 Web Server 也一样。 下面这段代码会监听 9009 端口,并在收到 HTTP 请求后,输出一些信息: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('remoteAddress: ' + req.connection.remoteAddress + '\n'); res.write('x-forwarded-for: ' + req.headers['x-forwarded-for'] + '\n'); res.write('x-real-ip: ' + req.headers['x-real-ip'] + '\n'); res.end(); }).listen(9009, '0.0.0.0'); 这段代码除了前面介绍过的 Remote Address 和 X-Forwarded-For,还有一个 X-Real-IP,这又是一个自定义头部字段。X-Real-IP 通常被 HTTP 代理用来表示与它产生 TCP 连接的设备 IP,这个设备可能是其他代理,也可能是真正的请求端。需要注意的是,X-Real-IP 目前并不属于任何标准,代理和 Web 应用之间可以约定用任何自定义头来传递这个信息。 现在可以用域名 + 端口号直接访问这个 Node.js 服务,再配一个 Nginx 反向代理: location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:9009/; proxy_redirect off; } 我的 Nginx 监听 80 端口,所以不带端口就可以访问 Nginx 转发过的服务。 测试直接访问 Node 服务: curl http://t1.imququ.com:9009/ remoteAddress: 114.248.238.236 x-forwarded-for: undefined x-real-ip: undefined 由于我的电脑直接连接了 Node.js 服务,Remote Address 就是我的 IP。同时我并未指定额外的自定义头,所以后两个字段都是 undefined。 再来访问 Nginx 转发过的服务: curl http://t1.imququ.com/ remoteAddress: 127.0.0.1 x-forwarded-for: 114.248.238.236 x-real-ip: 114.248.238.236 这一次,我的电脑是通过 Nginx 访问 Node.js 服务,得到的 Remote Address 实际上是 Nginx 的本地 IP。而前面 Nginx 配置中的这两行起作用了,为请求额外增加了两个自定义头: proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 实际上,在生产环境中部署 Web 应用,一般都采用上面第二种方式,有很多好处。但这就引入一个隐患:很多 Web 应用为了获取用户真正的 IP,从 HTTP 请求头中获取 IP。 HTTP 请求头可以随意构造,我们通过 curl 的 -H 参数构造 X-Forwarded-For 和 X-Real-IP,再来测试一把。 直接访问 Node.js 服务: curl http://t1.imququ.com:9009/ -H 'X-Forwarded-For: 1.1.1.1' -H 'X-Real-IP: 2.2.2.2' remoteAddress: 114.248.238.236 x-forwarded-for: 1.1.1.1 x-real-ip: 2.2.2.2 对于 Web 应用来说,X-Forwarded-For 和 X-Real-IP 就是两个普通的请求头,自然就不做任何处理原样输出了。这说明,对于直连部署方式,除了从 TCP 连接中得到的 Remote Address 之外,请求头中携带的 IP 信息都不能信。 访问 Nginx 转发过的服务: curl http://t1.imququ.com/ -H 'X-Forwarded-For: 1.1.1.1' -H 'X-Real-IP: 2.2.2.2' remoteAddress: 127.0.0.1 x-forwarded-for: 1.1.1.1, 114.248.238.236 x-real-ip: 114.248.238.236 这一次,Nginx 会在 X-Forwarded-For 后追加我的 IP;并用我的 IP 覆盖 X-Real-IP 请求头。这说明,有了 Nginx 的加工,X-Forwarded-For 最后一节以及 X-Real-IP 整个内容无法构造,可以用于获取用户 IP。 用户 IP 往往会被使用与跟 Web 安全有关的场景上,例如检查用户登录地区,基于 IP 做访问频率控制等等。这种场景下,确保 IP 无法构造更重要。经过前面的测试和分析,对于直接面向用户部署的 Web 应用,必须使用从 TCP 连接中得到的 Remote Address;对于部署了 Nginx 这样反向代理的 Web 应用,在正确配置了 Set Header 行为后,可以使用 Nginx 传过来的 X-Real-IP 或 X-Forwarded-For 最后一节(实际上它们一定等价)。 那么,Web 应用自身如何判断请求是直接过来,还是由可控的代理转发来的呢?在代理转发时增加额外的请求头是一个办法,但是不怎么保险,因为请求头太容易构造了。如果一定要这么用,这个自定义头要够长够罕见,还要保管好不能泄露出去。 判断 Remote Address 是不是本地 IP 也是一种办法,不过也不完善,因为在 Nginx 所处服务器上访问,无论直连还是走 Nginx 代理,Remote Address 都是 127.0.0.1。这个问题还好通常可以忽略,更麻烦的是,反向代理服务器和实际的 Web 应用不一定部署在同一台服务器上。所以更合理的做法是收集所有代理服务器 IP 列表,Web 应用拿到 Remote Address 后逐一比对来判断是以何种方式访问。 通常,为了简化逻辑,生产环境会封掉通过带端口直接访问 Web 应用的形式,只允许通过 Nginx 来访问。那是不是这样就没问题了呢?也不见得。 首先,如果用户真的是通过代理访问 Nginx,X-Forwarded-For 最后一节以及 X-Real-IP 得到的是代理的 IP,安全相关的场景只能用这个,但有些场景如根据 IP 显示所在地天气,就需要尽可能获得用户真实 IP,这时候 X-Forwarded-For 中第一个 IP 就可以排上用场了。这时候需要注意一个问题,还是拿之前的例子做测试: curl http://t1.imququ.com/ -H 'X-Forwarded-For: unknown, <>"1.1.1.1' remoteAddress: 127.0.0.1 x-forwarded-for: unknown, <>"1.1.1.1, 114.248.238.236 x-real-ip: 114.248.238.236 X-Forwarded-For 最后一节是 Nginx 追加上去的,但之前部分都来自于 Nginx 收到的请求头,这部分用户输入内容完全不可信。使用时需要格外小心,符合 IP 格式才能使用,不然容易引发 SQL 注入或 XSS 等安全漏洞。 结论 直接对外提供服务的 Web 应用,在进行与安全有关的操作时,只能通过 Remote Address 获取 IP,不能相信任何请求头; 使用 Nginx 等 Web Server 进行反向代理的 Web 应用,在配置正确的前提下,要用 X-Forwarded-For 最后一节 或 X-Real-IP 来获取 IP(因为 Remote Address 得到的是 Nginx 所在服务器的内网 IP);同时还应该禁止 Web 应用直接对外提供服务; 在与安全无关的场景,例如通过 IP 显示所在地天气,可以从 X-Forwarded-For 靠前的位置获取 IP,但是需要校验 IP 格式合法性; PS:网上有些文章建议这样配置 Nginx,其实并不合理: proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; 这样配置之后,安全性确实提高了,但是也导致请求到达 Nginx 之前的所有代理信息都被抹掉,无法为真正使用代理的用户提供更好的服务。还是应该弄明白这中间的原理,具体场景具体分析。 原文地址:https://imququ.com/post/x-forwarded-for-header-in-http.html$sent_http_NAME #可以设置任意http响应头字段;变量名中的后半部分NAME可以替换成任意响应头字段,如需要设置响应头Content-length,$sent_http_content_length即可 $sent_http_cache_control $sent_http_connection $sent_http_content_type $sent_http_keep_alive $sent_http_last_modified $sent_http_location $sent_http_transfer_encoding
自定义变量:
自己定义
:
删除编辑过的临时文件:
2-18 Nginx日志_log_format2 (04:20)
[root@192 ~]# pwd /root [root@192 ~]# cd /etc/nginx/ [root@192 nginx]# ls conf.d mime.types nginx.conf uwsgi_params fastcgi_params modules scgi_params [root@192 nginx]# cat nginx.conf user nginx; worker_processes auto; #配置nginx错误日志的地方: 记录了nginx错误日志的位置 warn 表示错误日志的级别为:warning(警告) notice、notice # 日志内容: 日期 、错误日志级别、对应错误代码、错误发生的行为描述、用户请求的信息、用户的IP信息、 error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; #log_format 的name名称为:main 其内容为:外层为'',其内层包含多个参数。 #nginx 变量: $remote_addr :客户端的地址 #nginx 变量: $remote_user :用于HTTP基础认证服务的用户名.如果nginx有配置认证,该变量代表客户端认证的用户名 #nginx 变量: [$time_local] 服务器时间(LOG Format 格式) #nginx 变量: $request 请求的连接,包括documenturi和args.#这个变量等于包含一些客户端请求参数的原始URI,它无法修改,请查看$uri更改或重写URI,不包含主机名,例如:"/cnphp/test.php?arg=freemouse" #nginx 变量: $status HTTP响应代码 #nginx 变量: $body_bytes_sent 传输给客户端的字节数,响应头不计算在内;这个变量和Apache的mod_log_config模块中的"%B"参数保持兼容 #nginx 变量: $http_referer url跳转来源,用来记录从那个页面链接访问过来的.客户端请求时的referer,通俗讲就是该请求时通过哪个连接跳进来的,也就是我们在百度搜一个关键字,然后可以点击条目跳进一个网站,点击的那个链接就是你的referer,用curl -e可以指定。 #nginx 变量: $http_user_agent 用户终端浏览器等信息 #nginx 变量: $http_x_forwarded_for log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; # access_log access_log文件存放路径 记录nginx log_format的name信息。 access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } [root@192 nginx]#
2-19 Nginx模块讲解_模块介绍 (01:35)
那么从这节课开始,我们进入到nginx模块的学习。
说到nginx的模块,我们可以把它分为index的官方模块 和 第三方模块。
官方模块是nginx的官方,也就是nginx.org。
我们下载的源码包里面所默认携带的模块,以及它所支持在官方里面有明显的所支持的模块,那么没有得到官方默认支持的模块,那么就是第三方模块。
有一些其他公司对index做的一些模块的开发,以及开源出来我们可以使用或者我们自己开发的模块,我们都称呼为第三方模块。
那么第三方模块的话在index加ur课程的学习里面,我会为大家做一些提醒。
那么nginx的官方模块是我们这一章将会。
大家重点介绍的,我们登录到自己的服务器上。
记得有给大家讲过nginx -V,我们可以查看到nginx编译的相关的参数,那么其中就包括了我们所编译的模块。
[root@192 nginx]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx # 以“--with” 开头的模块都是nginx 默认开启或者 编连进去的模块 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
那么这节课起呢我将为大家讲解一些大部分你们默认所用到的模块,以及它对应的配置。
2-20 Nginx模块讲解_sub_status :展示Nginx的客户端状态信息
模块内容讲解:
[root@192 nginx]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx # 以“--with” 开头的模块都是nginx 默认开启或者 编连进去的模块 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module #http_stub_status_module:nginx默认编译添加选项。主要用于展示nginx当前处理连接的一个状态。用于监控nginx 当前的一个连接的信息。 # 配置语法: # Syntax:stub_status: # Default:-- #默认是没有配置的,它需要基于server下的location这一级配置下面来进行配置 # Context:server,location --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'配置说明:
[root@192 conf.d]# pwd /etc/nginx/conf.d [root@192 conf.d]# [root@192 nginx]# ls conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params [root@192 nginx]# cd conf.d/ [root@192 conf.d]# ls default.conf [root@192 conf.d]# cat default.conf server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } [root@192 conf.d]# vi default.conf server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; #配置http_stub_status_module #http_stub_status_module:nginx默认编译添加选项。主要用于展示nginx当前处理连接的一个状态。用于监控nginx 当前的一个连接的信息。 # 配置语法: # Syntax:stub_status; # Default:-- #默认是没有配置的,它需要基于server下的location这一级配置下面来进行配置 # Context:server,location location /mystatus{ stub_status; #以分号结尾 } location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; "default.conf" 49L, 1137C written #检查配置文件编写是否正确 [root@192 conf.d]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful #重载服务 [root@192 conf.d]# nginx -s reload -c /etc/nginx/nginx.conf # 查看nginx 服务器的ip信息 [root@192 conf.d]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:cc:38:6c brd ff:ff:ff:ff:ff:ff inet 192.168.0.21/24 brd 192.168.0.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::8837:7fda:866c:e3c1/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:78:65:11 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:78:65:11 brd ff:ff:ff:ff:ff:ff [root@192 conf.d]# #打开浏览器,访问 nginx服务器的ip(192.168.0.21)地址/mystatus 的路径信息
Active connections: 2 # nginx当前活跃的连接数 #展示了三个数,这三个数都是一个总值。第一个数表示nginx处理的接受的这个握手的总的次数; 第二个表示nginx处理的连接数;第三个表示nginx的总的请求数 server accepts handled requests 7 7 9 #正常情况:握手(第一个数:7) 与连接数(第二个数:7)是相等的,则表示这数据请求没有丢失。 Reading: 0 Writing: 1 Waiting: 1 #表示当前的一个状态。 read 0 表示当前读的个数,Writing: 1表示当前正在往nginx里写的个数 Waiting: 1 表示主要是在nginx开启里keeplift(长连接)的情况下,客户端和服务器端正在空闲等待的数据。即:即没有写 也没有读但建立连接的数据量
2-21 Nginx模块讲解_random_index :随机选择一个主界面
模块内容说明:
[root@192 nginx]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx # 以“--with” 开头的模块都是nginx 默认开启或者 编连进去的模块 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module # http_random_index_module :niginx 默认安装抓包rmp的一个模块。 # 主要作用:用来在它的主目录里面随机的选择一个文件作为它的默认的随机主页 # 使用频率:很少。只在某些特定场景使用,如:多个主页界面随机展示给用户看,用以体现不同的体验感觉 # 配置语法: # Syntax: random_index on|off # Default: random_index off; # 默认是关闭状态 # Context: location # 配置限制在location 配置里面 # 注意要点:这里会选择指定文件路径(如:示例 /opt/app/code)下的文件(如示例:1.html/2.html/3.html)作为随机展示主页信息。而不会使用 以“.”开头的文件作为随机文件来展示主页 # # --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module
--with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
配置演示:
[root@192 conf.d]# pwd #查看文件当前路径信息 /etc/nginx/conf.d [root@192 conf.d]# cp default.conf /opt/backup/default.conf #备份修改配置文件 [root@192 conf.d]# vim default.conf #修改配置文件 server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; random_index on; #配置 random_index 信息 index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} "default.conf" 47L, 1107C written #创建并进入 测试代码路径 [root@192 conf.d]# cd /opt/app/ [root@192 app]# ls [root@192 app]# mkdir code [root@192 app]# cd code/ [root@192 code]# pwd /opt/app/code [root@192 code]# ls 1.html 2.html 3.html [root@192 code]# cat 1.html <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body style="background-color:red;" > </body> </html> [root@192 code]# cat 2.html <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body style="background-color:black;" > </body> </html> [root@192 code]# cat 3.html <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body style="background-color:blue;" > </body> </html> [root@192 code]# pwd /opt/app/code #把 /opt/app/code 的这路径写入到 /etc/nginx/conf.d/default.conf 文件里的 #location / { # root /usr/share/nginx/html; # random_index on; # index index.html index.htm; # } # 的 root /usr/share/nginx/html; 的配置里面。 即: root /opt/app/code [root@192 code]# vi /etc/nginx/conf.d/default.conf root /usr/share/nginx/html server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /opt/app/code; random_index on; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} "/etc/nginx/conf.d/default.conf" 47L, 1099C written [root@192 code]# # 检查下 nginx 配置文件修改是否正确。 [root@192 code]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@192 code]# #重新启动 nginx 服务 [root@192 code]# nginx -s reload -c /etc/nginx/nginx.conf [root@192 code]# systemctl reload nginx [root@192 code]# #查看nginx 进行信息 [root@192 code]# ps -aux |grep nginx root 28909 0.0 0.0 46636 2040 ? Ss Nov17 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 30128 0.0 0.0 49128 2040 ? S 00:34 0:00 nginx: worker process nginx 30129 0.0 0.0 49128 2040 ? S 00:34 0:00 nginx: worker process nginx 30130 0.0 0.0 49128 2040 ? S 00:34 0:00 nginx: worker process nginx 30131 0.0 0.0 49128 2040 ? S 00:34 0:00 nginx: worker process root 30133 0.0 0.0 112812 972 pts/1 S+ 00:35 0:00 grep --color=auto nginx [root@192 code]#查看配置效果:
1:初次访问
2:刷新界面:
3:刷新界面:
2-22 Nginx模块讲解_sub_module :http内容替换
[root@192 nginx]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx # 以“--with” 开头的模块都是nginx 默认开启或者 编连进去的模块 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module #http_sub_module :用于跟这个服务端在给客户端response http 的内容的时候,用于对http 的内容进行替换。 # 使用场景:如———:当http server 有多个是虚拟主机且需要对每一个虚拟主机的http的返回的html 的内容进行替换,或者是内容的变更。这个时候往往需要依赖开发进行代码的这个整理或者是修复,然后进行新一轮测试,再进行上线。因为这个迭代的周期是非常强的。用http several model 这个模块,就能很快的把指定的返回的内容替换成需求想要的内容,从而快捷变更返回给用户的整体效果。 #语法: # Syntax:sub_filter string replacement; # Default:-- # Context:http,server,location # # 说明: # String 表示 要替换的内容 # replacement 表示:要替换后的内容 # 使用范围: # http 级别:可以对多个server完成指定字符串的替换 # Server 级别: # location 级别 # #语法: # Syntax:sub_filter_last_modified on|off; # Default:sub_filter_last_modified off; #默认是关闭的,需要使用的时候,只要把off改为on. # Context:http,server,location #说明: # 使用范围: # http 级别:可以对多个server完成指定字符串的替换 # Server 级别: # location 级别: #使用作用:nginix服务端来校验客户端(浏览器端)的每一次请求时候,服务端的内容是否发生过变更。 改参数里有一串内容更新记录时间。且该内容是存放在http请求的头文件里面的。 主要目的是用来检查内容是否发生更新。如果发生更新返回给用户最新的内容,如果没有更新,就不需要。再一次返回html 的内容代码。这样的话会节省不必要的消耗。这个主要用于缓存的场景里面。 # # #语法: # Syntax:sub_filter_last_once on|off; # Default:sub_filter_last_once off; #默认是关闭的,需要使用的时候,只要把off改为on. # Context:http,server,location #说明: # 使用范围: # http 级别:可以对多个server完成指定字符串的替换 # Server 级别: # location 级别: # #使用作用:当在进行文件内容替换的时候,是替换匹配html里所有指定待匹配的内容还是其第一指定待匹配的内容。如果是on 指匹配第一个内容。如果是off 则是匹配使用相关的内容。 # # # # --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'示例:
2-23 Nginx模块讲解_sub_module配置演示 :http内容替换配置演示
# 找到 nginx 的default.conf文件位置,替换还原该文件 [root@192 code]# pwd /opt/app/code [root@192 code]# cat /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } [root@192 code]# cd /etc/nginx/conf.d/ [root@192 conf.d]# ls default.conf #替换还原该default.conf文件 [root@192 conf.d]# cp /opt/backup/default.conf default.conf cp: overwrite efault.conf #查看文件内容是否还原
[root@192 conf.d]# cat default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }#重新启动 nginx 应用 [root@192 conf.d]# nginx -s reload -c /etc/nginx/nginx.conf访问主界面:
#创建示例文件 submodule.html [root@192 conf.d]# cd /opt/app/code/ [root@192 code]# ls 1.html 2.html 3.html [root@192 code]# touch submodule.html [root@192 code]# ls 1.html 2.html 3.html submodule.html [root@192 code]# cat submodule.html <html> <head> <meta charset="utf-8"> <title>submodules</title> </head> <body> <a>jeson</a> <a>at</a> <a>imooc</a> <a>jeson</a> <a>imooc</a> </body> </html> [root@192 code]#
#修改 default.conf 配置文件 root的主目录 信息 [root@192 conf.d]# ls default.conf [root@192 conf.d]# vi default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { # root /usr/share/nginx/html; root /opt/app/code; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root "default.conf" [dos] 46L, 1178C written #检查配置文件修改情况 是否符合要求 [root@192 conf.d]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful #重新启动 nginx应用 [root@192 conf.d]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@192 conf.d]#
查看界面显示效果
#修改 default.conf 配置文件。增加 替换请求文件内容。 [root@192 conf.d]# vi default.conf random_index on; server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { # root /usr/share/nginx/html; root /opt/app/code; random_index on; index index.html index.htm; #sub_filter '1' '2' ; 1为要替换内容 2 为替换后展示的内容 此配置内容为:只替换第一次出现的要替换的内容进行替换 sub_filter '<a>imooc' '<a>IMOCC_sub_filter_test'; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; "default.conf" [dos] 49L, 1272C written [root@192 conf.d]#[root@192 conf.d]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@192 conf.d]# systemctl reload nginx; [root@192 conf.d]#[root@192 conf.d]# vi default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { # root /usr/share/nginx/html; root /opt/app/code; random_index on; index index.html index.htm; #sub_filter '1' '2' ; 1为要替换内容 2 为替换后展示的内容 此配置内容为:只替换第一次出现的要替换的内容进行替换 sub_filter '<a>imooc' '<a>IMOCC_sub_filter_test '; # 全局性替换修改。 替换所有的出现的要出现的内容 sub_filter_once off; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 404 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; "default.conf" [dos] 50L, 1304C written [root@192 conf.d]#[root@192 conf.d]# nginx -tc /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@192 conf.d]# systemctl reload nginx; [root@192 conf.d]#
2-24 Nginx的请求限制_连接频率限制配置语法与原理
#limit_conn_module:避免针对连接频率的限制 #limit_req_module :针对请求频率的限制 #两者差别:1:实现原理是不一样的,2:作用范围不同:在连接和请求上 #两者相同点:都可以实现分级的请求性质的限制#http协议的连接与请求 # http协议是建立在tcp协议的基础之上,要完成一次tcp的请求,先要进行tcp的三次握手。 #这个图就大概给大家画了一个从客户端到服务端的三次握手。 # 这个时候先进行tcp的三次摸索,这个状态称之为是tcp的连接。建立好了tcp的连接,这个时候才会进行http的request和这个response的请求和响应。 #在连接的基础之上然后再来进行http的请求,当今的这个http的协议的时代,已经可以让我们在一个连接的基础之上建立多次请求,比如这张图里面所画的,先进行完tcp的三次握手的连接以后,然后进行http的请求响应,最后用客户端和服务端不断的发送FIN、ACK 包来保持这个连接的状,也就是我们所讲的长面积和keyword。 #通过这个图我们可以明白,连接是建立在http请求的基础之上。 #总结,在http不同协议的版本的时候,连接和请求它有对应的这个限制 # 在老的http1.0 版本的时候,http是不能复用的,也就是客户端向服务端发送请求以后,服务端在对应的时间里面就会断开,完成一次hd请求的时候就会断开,一次连接就对应着一次请求。 #在当今主流的http1.1 议版本,一个连接就可以顺序性地被复用,而发起多次的、继续性的http请求。 #在当今主流的http2.0 议协议版本以后,已经是一个连接多路的、并行的进行http的请求。#总结出http请求是建立在一次tcp的连接基础之上,然后一次tcp的请求至少可以产生一次http请求,也可以产生多次http请求。
n这个连接和请求以后,我们讲nginx于连接和请求的限制,它的语法在这里我把针对连接的配置语法。
# limit_conn_zone 空间存储需要限制ip的连接的这个状态内存空间。如以客户端的ip为key,则限制的是客户端的ip连接。 # key 还可以使用其他位置变量来做限制。 # zone=name 表示对限制的key内容在内容申请的内存空间名称。方便后面进行限制时候方便调用这个限制空间的名称进行限制操作。 # size:表示申请空间的大小:如1M、10M、100M # Syntax: limit_conn_zone key zone=name:size; # Default:-- # Context : http # limit_conn 要先定义好zone空间名称,才能在此使用连接限制操作。 # zone 即是 limit_conn_zone 里配置的 zone=name 的信息 # number 配置限制同时间上并发的数量:1表示 1个并发 10 表示10个并发 # Syntax: limit_conn zone number; # Default:-- # Context: http,server,location
# limit_req_zone 空间存储需要限制ip的请求的这个状态内存空间。 # 如以客户端的ip为key,则限制的是客户端的ip请求。key 还可以使用其他位置变量来做限制。 # zone=name 表示对限制的key内容在内容申请的内存空间名称。方便后面进行限制时候方便调用这个限制空间的名称进行限制操作。 # size:表示申请空间的大小:如1M、10M、100M # rate=reate 对于请求的限制,以秒为单位,然后这个请求是以多少秒的单位个数限制 # # Syntax: limit_req_zone key zone=name:size rate=reate # Default:-- # Context:http # # limit_req 的 zone 是要limit_req_zone 先定义好zone空间名称,才能在此使用连接限制操作。 # zone 即是 limit_req_zone 里配置的 zone=name 的信息 # [ burst=number ] [ nodelay ] 默认情况是无需配置 # [ burst=number ] 表示: # [ nodelay ] 表示: # Syntax: limit_req zone=name [ burst=number ] [ nodelay ] # Default:-- # Context:http,server,location # #
2-25 Nginx的请求限制_请求限制配置演示
2-26 Nginx的请求限制_请求限制配置语法 (06:58)
2-27 Nginx的访问控制_介绍实现访问控制的基本方式 (00:58)
2-28 Nginx的访问控制—access_module配置语法介绍 (01:08)
2-29 Nginx的访问控制—access_module配置 (09:51)
2-30 Nginx的访问控制—access_module局限性 (06:35)
2-31 Nginx的访问控制—auth_basic_module配置 (07:42)
2-32 Nginx的访问控制—auth_basic_module局限性 (01:41)
2-33 【讨论题】结合HTTP不同版本协议,聊聊Nginx的应用
2-34 【讨论题】聊聊你为什么要使用Nginx?
第3章 场景实践篇
Nginx作为静态资源web服务的场景应用,Nginx做为http代理服务,介绍代理服务的类型,正向反向代理配置,重点讲解nginx作为的应用层负载均衡服务的各种应用,hash负载均衡策略,Nginx缓存等
3-1 场景实践篇内容介绍 (02:02)
3-2 Nginx作为静态资源web服务_静态资源类型 (02:47)
3-3 Nginx作为静态资源web服务_CDN场景 (02:33)
3-4 Nginx作为静态资源web服务_配置语法 (06:20)
3-5 Nginx作为静态资源web服务_场景演示 (12:30)
3-6 Nginx作为静态资源web服务_浏览器缓存原理 (07:11)
3-7 Nginx作为静态资源web服务_浏览器缓存场景演示 (08:56)
3-8 Nginx作为静态资源web服务_跨站访问 (04:13)
3-9 Nginx作为静态资源web服务_跨域访问场景配置 (05:05)
3-10 Nginx作为静态资源web服务_防盗链目的 (03:12)
3-11 Nginx作为静态资源web服务_防盗链配置 (07:34)
3-12 Nginx作为代理服务_代理服务 (07:14)
3-13 Nginx作为代理的模式和使用模块介绍 (10:55)
3-14 Nginx作为代理服务_配置语法及反向代理场景 (05:51)
3-15 Nginx作为代理服务_正向代理配置场景(1) (02:29)
3-16 Nginx作为代理服务_正向代理配置场景(2) (04:09)
3-17 Nginx作为代理服务_代理配置语法补充 (06:12)
3-18 Nginx作为代理服务_代理补充配置和规范 (05:12)
3-19 Nginx作为缓存服务_Nginx作为缓存服务 (02:52)
3-20 Nginx作为缓存服务_缓存服务配置语法 (02:12)
3-21 Nginx作为缓存服务_场景配置演示 (07:44)
3-22 Nginx作为缓存服务_场景配置补充说明 (03:24)
3-23 Nginx缓存命中分析 (10:28)
3-24 Nginx统计日志进行缓存命率中分析 (13:49)
3-25 Nginx作为缓存服务_分片请求 (02:01)
3-26 什么是Websocket以及Nginx实现ws代理 (06:35)
3-27 基于nodejs实现websocket代理场景配置演示 (12:53)
3-28 什么是fastcgi代理及配置语法 (11:13)
3-29 LNMP基础环境安装 (07:06)
3-30 Fastcgi代理配置演示及测试 (10:07)
3-31 LNMP配置演示1-搭建wordpress博客系统 (09:55)
3-32 LNMP配置演示2-搭建wordpress博客系统 (12:17)
3-33 Fastcgi缓存配置演示 (14:18)
3-34 场景演示:后端服务添加no-cache头对于Nginx代理缓存的影响 (09:20)
3-35 场景演示:设置缓存维度fastcgi_cache_key设置的影响 (04:52)
3-36 Uwsgi反向代理模式 (12:39)
3-37 基于Django框架Uwsgi反向代理配置演示 (14:23)
3-38 Nginx作为负载均衡服务_负载均衡与Nginx (05:28)
3-39 Nginx作为负载均衡服务_配置场景 (07:20)
3-40 Nginx作为负载均衡服务_backup状态演示 (06:14)
3-41 Nginx作为负载均衡服务_轮询策略与加权轮询 (01:56)
3-42 Nginx作为负载均衡服务_负载均衡策略ip_hash方式 (02:54)
3-43 Nginx作为负载均衡服务_负载均衡策略url_hash策略 (05:54)
3-44 【讨论题】对于不同应用场景你是如何来优化Nginx的
第4章 深度学习篇 34 节 | 133分钟
Nginx常用配置模块,rewirte的配置语法和规则,配置基于指定地域的规则访问,geoip模块、https的实现原理,配置nginx的https服务,secure_link_module的防盗链实现,讲解,讲解Lua的开发语法、配合Nginx实现高效的认证系统和其他场景。
4-1 Nginx动静分离_动静分离场景演示(1) (02:45)
4-2 Nginx动静分离_动静分离场景演示 (04:43)
4-3 Nginx动静分离_动静分离场景演示(2) (02:28)
4-4 Rewrite规则_rewrite规则作用 (02:32)
4-5 Rewrite规则_rewrite配置语法 (01:28)
4-6 Rewrite规则_rewrite正则表达式 (05:42)
4-7 Rewrite规则_rewrite规则中的flag (05:24)
4-8 Rewrite规则_redirect和permanent区别 (06:38)
4-9 Rewrite规则_rewrite规则场景(1) (03:45)
4-10 Rewrite规则_rewrite规则场景(2) (01:44)
4-11 Rewrite规则_rewrite规则书写 (02:09)
4-12 Nginx进阶高级模块_secure_link模块作用原理 (06:05)
4-13 Nginx进阶高级模块_secure_link模块实现请求资源验证 (08:26)
4-14 Nginx进阶高级模块_Geoip读取地域信息模块介绍 (02:56)
4-15 Nginx进阶高级模块_Geoip读取地域信息场景展示 (06:15)
4-16 基于Nginx的HTTPS服务_HTTPS原理和作用1 (07:06)
4-17 基于Nginx的HTTPS服务_HTTPS原理和作用2 (01:47)
4-18 基于Nginx的HTTPS服务_证书签名生成CA证书 (03:57)
4-19 基于Nginx的HTTPS服务_证书签名生成和Nginx的HTTPS服务场景演示1 (09:18)
4-20 基于Nginx的HTTPS服务_证书签名生成和Nginx的HTTPS服务场景演示2 (01:53)
4-21 基于Nginx的HTTPS服务_实战场景配置苹果要求的openssl后台HTTPS服务1 (04:03)
4-22 基于Nginx的HTTPS服务_实战场景配置苹果要求的openssl后台HTTPS服务2 (03:58)
4-23 基于Nginx的HTTPS服务_实战场景配置苹果要求的openssl后台HTTPS服务3 (01:34)
4-24 基于Nginx的HTTPS服务_HTTPS服务优化 (03:06)
4-25 Nginx与Lua的开发_Nginx与Lua特性与优势 (02:21)
4-26 Nginx与Lua的开发_Lua基础开发语法1 (02:01)
4-27 Nginx与Lua的开发_Lua基础开发语法2 (02:35)
4-28 Nginx与Lua的开发_Nginx与Lua的开发环境 (02:30)
4-29 Nginx与Lua的开发_Nginx调用Lua的指令及Nginx的Luaapi接口 (02:24)
4-30 Nginx与Lua的开发_实战场景灰度发布 (03:20)
4-31 Nginx与Lua的开发_实战场景灰度发布场景演示1 (03:01)
4-32 Nginx与Lua的开发_实战场景灰度发布场景演示2 (10:55)
4-33 Nginx与Lua的开发_实战场景灰度发布场景演示3 (01:35)
4-34 Nginx与Lua的开发_实战场景灰度发布场景演示4 (01:36)
第5章 Nginx架构篇 35 节 | 124分钟
Nginx常见问题和排错经验,实践应用场景中的方法处理Nginx安全,常见的应用层安全隐患,复杂访问控制,Nignx的sql防注入安全策略,Nginx的整体配置,搭建合理Nginx中间件架构配置步骤、策略Nginx性能优化:架构优化,操作系统优化、Nginx优化等...
5-1 Nginx常见问题_架构篇介绍 (01:13)
5-2 Nginx常见问题__多个server_name中虚拟主机读取的优先级 (04:44)
5-3 Nginx常见问题_多个location匹配的优先级1 (01:19)
5-4 Nginx常见问题_多个location匹配的优先级2 (02:08)
5-5 Nginx常见问题_try_files使用 (04:15)
5-6 Nginx常见问题_alias和root的使用区别 (01:57)
5-7 Nginx常见问题_如何获取用户真实的ip信息 (01:47)
5-8 Nginx常见问题_Nginx中常见错误码 (02:40)
5-9 Nginx的性能优化_内容介绍及性能优化考虑 (03:41)
5-10 Nginx的性能优化_ab压测工具 (02:01)
5-11 Nginx的性能优化_ab压测工具1 (04:29)
5-12 Nginx的性能优化_ab压测工具2 (03:32)
5-13 Nginx的性能优化_ab压测工具3 (03:16)
5-14 Nginx的性能优化_系统与Nginx性能优化 (02:15)
5-15 Nginx的性能优化_文件句柄设置 (05:28)
5-16 Nginx的性能优化_CPU亲和配置1 (04:33)
5-17 Nginx的性能优化_CPU亲和配置2 (03:02)
5-18 Nginx的性能优化_Nginx通用配置优化 (07:18)
5-19 Nginx安全_基于Nginx的安全章节内容介绍 (01:20)
5-20 Nginx安全_恶意行为控制手段 (03:58)
5-21 Nginx安全_攻击手段之暴力破解 (02:55)
5-22 Nginx安全_文件上传漏洞 (03:08)
5-23 Nginx安全_SQL注入 (01:38)
5-24 Nginx安全_SQL注入场景说明 (02:01)
5-25 Nginx安全_场景准备mariadb和lnmp环境 (08:39)
5-26 Nginx安全_模拟SQL注入场景 (06:08)
5-27 Nginx安全_Nginx+LUA防火墙功能 (04:09)
5-28 Nginx安全_Nginx+LUA防火墙防sql注入场景演示 (11:50)
5-29 Nginx安全_复杂的访问攻击中CC攻击方式 (02:07)
5-30 Nginx安全_Nginx版本更新和本身漏洞 (03:17)
5-31 Nginx架构总结_静态资源服务的功能设计 (04:40)
5-32 Nginx架构总结_Nginx作为代理服务的需求 (02:08)
5-33 Nginx架构总结_需求设计评估 (05:53)
5-34 【讨论题】结合应用安全聊聊你所理解的Nginx安全
5-35 【讨论题】你负责的应用中哪些用到了Nginx rewrite
第6章 新特性篇 6 节 | 60分钟
本章节结合当前主流最新应用场景,或者基于Nginx版本更新带来的最新重要特性,
讲解:Nginx版本平滑升级、HTTP2.0协议、gRPC应用网关场景等等,
作为新特性篇后续本章的内容将持续更新…
6-1 Nginx平滑升级实现和原理 (11:39)
6-2 Nginx进行版本平滑升级演示 (14:52)
6-3 HTTP协议版本及HTTP2.0协议特性gRPC (05:44)
6-4 GO及gRPC测试用例环境安装准备 (14:04)
6-5 Nginx作为gRPC应用网关配置案例演示 (12:57)
6-6 完结散花 (00:33)
学问:纸上得来终觉浅,绝知此事要躬行
为事:工欲善其事,必先利其器。
态度:道阻且长,行则将至;行而不辍,未来可期
.....................................................................
------- 桃之夭夭,灼灼其华。之子于归,宜其室家。 ---------------
------- 桃之夭夭,有蕡其实。之子于归,宜其家室。 ---------------
------- 桃之夭夭,其叶蓁蓁。之子于归,宜其家人。 ---------------
=====================================================================
* 博客文章部分截图及内容来自于学习的书本及相应培训课程以及网络其他博客,仅做学习讨论之用,不做商业用途。
* 如有侵权,马上联系我,我立马删除对应链接。 * @author Alan -liu * @Email no008@foxmail.com
转载请标注出处! ✧*꧁一品堂.技术学习笔记꧂*✧. ---> https://www.cnblogs.com/ios9/