LINUX

nginx配置介绍

nginx配置介绍

nginx快速编译安装

yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel

wget http://nginx.org/download/nginx-1.14.1.tar.gz   
 
tar -zxvf nginx-1.14.1.tar.gz 

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_slice_module --with-http_stub_status_module
make && make install

main (全局设置), main 部分设置的指令将影响其它所有部分的设置; http(http服务器设置)http标准核心模块,http服务的相应配置 server (主机设置) 接收请求的服务器需要将不同的请求按规则转发到不同的后端服务器上,在 nginx 中我们可以通过构建虚拟主机( server )的概念来将这些不同的服务配置隔 离location URL匹配特定位置后的设置), location 部分用于匹配网页位置(比如,根目录“/”,“/images”,等等), server 是对应一个域名进行的配置,而 location 是在一个域名下对更精细的路径进行配置.

微信截图_20211014134542.png

1、配置文件由指令与指令块构成 

2、每条指令以;分号结尾,指令与参数间以空格符号分隔 

3、指令块以{}大括号将多条指令组织在一起 

4、使用#符号添加注释,提高可读性 

5include语句允许组合多个配置文件以提升可维护性

6、使用$符号使用变量 

7、部分指令的参数支持正则表达式

Nginx的各种指令以及配置繁多,有些配置可以在如下的链接 https://tengine.taobao.org/nginx_docs/cn/docs/ 或者在官方文档上查看

nginx常用命令

1、查看Nginx的版本号:nginx -V 
2、停止 nginx -s stop
(0)
分享:

本文由:xiaoshu168.com 作者:xiaoshu发表,转载请注明来源!

相关阅读