nginx 的编译安装及基本操作
下载nginx
[root@nginx ~]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
--2019-05-02 21:52:23-- http://nginx.org/download/nginx-1.14.0.tar.gz
正在解析主机 nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3
正在连接 nginx.org (nginx.org)|95.211.80.227|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1016272 (992K) [application/octet-stream]
正在保存至: “nginx-1.14.0.tar.gz” 100%[=====================================================================================================================================================>] 1,016,272 74.5KB/s 用时 13s 2019-05-02 21:52:43 (74.0 KB/s) - 已保存 “nginx-1.14.0.tar.gz” [1016272/1016272])
创建系统目录用户解压编译安装
[root@nginx ~]# useradd -r nginx
[root@nginx ~]# mkdir /etc/nginx
[root@nginx ~]# mkdir /data/web
[root@nginx ~]# tar xf nginx-1.14.0.tar.gz
[root@nginx ~]# cd nginx-1.14.0
[root@nginx nginx-1.14.0]# ./configure --prefix=/data/web --user=nginx --group=nginx --sbin-path=/usr/bin --conf-path=/etc/nginx
[root@nginx nginx-1.14.0]# make && make install
拷贝contrib/vim/*的文件到~/.vim目录下
[root@nginx nginx-1.14.0]# mkdir ~/.vim
[root@nginx nginx-1.14.0]# cp -r contrib/vim/* ~/.vim/
编译时参数介绍
[root@nginx nginx-1.14.0]# ./configure --help | more --help print this message --prefix=PATH set installation prefix 安装目录
--sbin-path=PATH set nginx binary pathname 可执行文件目录
--modules-path=PATH set modules path 依赖模块目录
--conf-path=PATH set nginx.conf pathname 配置文件目录
--error-log-path=PATH set error log pathname 错误日志目录
--pid-path=PATH set nginx.pid pathname pid文件目录
--lock-path=PATH set nginx.lock pathname 日志目录文件 --user=USER set non-privileged user for 运行的用户
worker processes
--group=GROUP set non-privileged group for 运行的组
worker processes --build=NAME set build name
--builddir=DIR set build directory --with-select_module enable select module
--without-select_module disable select module
--with-poll_module enable poll module
--without-poll_module disable poll module --with-threads enable thread pool support --with-file-aio enable file AIO support --with-http_ssl_module enable ngx_http_ssl_module
--with-http_v2_module enable ngx_http_v2_module
--with-http_realip_module enable ngx_http_realip_module
如果要升级
[root@nginx nginx-1.14.0]# ./configure --prefix=/data/web --user=nginx --group=nginx --sbin-path=/usr/bin --conf-path=/etc/nginx
[root@nginx nginx-1.14.0]# make
[root@nginx objs]# cp -a nginx /usr/bin 注意不可执行make install,把二进制文件复制过去
nginx配置语法
1.配置文件由指令与指令块构成
2.每条指令以;分号结尾,指令与参数之间空格隔开
3.指令块以{}大括号将多条指令组合在一起
4.include语句允许组合多个配置文件以提升可维护性
5.使用#添加注释,提高可读性
6.使用$符号使用变量
7.部分指令参数支持正则表达式
时间单位的表达
ms 毫秒 s 秒 m 分钟 h 小时 d 天 w 周 M 月 y 年
空间单位
什么也不加表示字节 k/K 表示千字节 m/M 表示兆字节 g/G 表示G字节
nginx 命令行格式介绍
[root@nginx objs]# nginx -? -?或者-h 显示帮助
-c 指定配置文件;默认读取编译时指定路径下的配置文件
-g 指定配置指令;可以覆盖配置文件里的配置指令
-p 指定运行目录
-s 发送信号;stop:立刻停止 quit:优雅停止服务 reload:重载配置文件 reopen :重新记录日志文件
-t 检查配置文件语法是否错误
-v 打印版本
nginx的热部署
[root@nginx ~]# cd nginx-1.15.12
[root@nginx nginx-1.15.12]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@nginx nginx-1.15.12]# ./configure --prefix=/data/web --user=nginx --group=nginx --sbin-path=/usr/bin
[root@nginx nginx-1.15.12]# make
[root@nginx nginx-1.15.12]# mv /usr/bin/nginx{,.bak}
[root@nginx nginx-1.15.12]# cp objs/nginx /usr/bin/
[root@nginx ~]# ps -aux | grep nginx | grep root 查出nginx主进程的pid号
root 40343 0.0 0.1 20544 1348 ? Ss 23:19 0:00 nginx: master process nginx
[root@nginx ~]# kill -USR2 40343 向这个进程发送我要升级信号
[root@nginx ~]# ps -ef | grep nginx 升级完成
root 40343 1 0 23:19 ? 00:00:00 nginx: master process nginx
nginx 40354 40343 0 23:26 ? 00:00:00 nginx: worker process
root 42899 13537 0 23:42 pts/1 00:00:00 grep --color=auto nginx
[root@nginx ~]# kill -WINCH 40343 向主进程发送优雅关闭工作进程的信号
nginx 的编译安装及基本操作的更多相关文章
- Nginx 的编译安装和URL地址重写
本文转自:http://www.178linux.com/14119#rd?sukey=ecafc0a7cc4a741b573a095a3eb78af6b4c9116b74d0bbc9844d8fc5 ...
- nginx应用编译安装
nginx应用编译安装: 安装编译所需依赖包: # apt-get install make gcc g++ libcurl3-openssl-dev libfreetype6-dev libmcry ...
- nginx的编译安装以及启动脚本编写
Nginx的编译安装和启动脚本的编写 Nginxd的功能强大,可以实现代理.负载均衡等企业常用的功能.下面介绍一下nginx的编译安装方法: 1. 下载 官方下载地址:http://nginx.org ...
- 初识Nginx及编译安装Nginx
初识Nginx及编译安装Nginx 环境说明: 系统版本 CentOS 6.9 x86_64 软件版本 nginx-1.12.2 1.什么是Nginx? 如果你听说或使用过Apache软件 ...
- 【01】Nginx:编译安装/动态添加模块
写在前面的话 说起 Nginx,别说运维,就是很多开发人员也很熟悉,毕竟如今已经 2019 年了,Apache 更多的要么成为了历史,要么成为了历史残留. 我们在提及 Nginx 的时候,一直在强调他 ...
- 【nginx运维基础(1)】Nginx的编译安装与使用
nginx的官方手册: http://nginx.org/en/docs/ 编译安装 下载地址: http://nginx.org/en/download.html # 为了支持rewrite功能,我 ...
- Nginx服务编译安装、日志功能、状态模块及访问认证模式实操
系统环境 [root@web ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@web ~]# uname -a Linux d ...
- Nginx的编译安装及选项
编译安装Nginx1.安装常见的工具和库(GCC.PCRE.zlib.OpenSSL) Nginx是一个由C语言编写的,所以需要一个编译工具如GNU的GCC[root@www ~]# yum inst ...
- Nginx之编译安装的nginx加入systemctl
编译安装的nginx需要添加rc.local 编译安装后设置 /usr/lib/systemd/system/nginx.service [Unit] Description=nginx After= ...
随机推荐
- Cardboard profile的修改
Cardboard盒子中,手机屏幕大小.镜片离屏幕距离,屏幕分辨率等都会影响配戴者的眼中成像,通过对生成图像的变形可以部份解决这一问题,cardboard sdk中提供了cardboardprofil ...
- U3D 的一些基础优化
1.在使用数组或ArrayList对象时应当注意 [csharp] view plaincopy length=myArray.Length; for(int i=0;i<length;i++) ...
- NOIp 2015信息传递【tarjan/拓扑/并查集】
一道好的NOIp题目,在赛场上总能用许多算法A掉.比如这道和关押罪犯. 题目传送门 法一:tarjan在有向图中跑最小环 有人从别人口中得知自己信息,等效于出现了一个环.于是 这就变成了一个有向图ta ...
- 害死人不偿命的(3n+1)猜想 (15)
#include <iostream> #include <algorithm> using namespace std; int main(){ int n; while ( ...
- Hexo瞎折腾系列(6) - 将博客同时部署到Github和Coding
前言 由于本人只是将Hexo博客同时部署到 Github 和 Coding.net ,所以这里只介绍怎么同时部署到这两个网站的pages. 之所以选择这两个网站,是因为国外用户可以访问 Github, ...
- 洛谷 P2841 A*B Problem
https://www.luogu.org/problemnew/show/P2841 根本不会啊... 大概就是:如果两个数模a的结果相同,那么它们前面同时加上一个0或1后模a的结果仍然相同,因此可 ...
- 洛谷P3379lca,HDU2586,洛谷P1967货车运输,倍增lca,树上倍增
倍增lca板子洛谷P3379 #include<cstdio> struct E { int to,next; }e[]; ],anc[][],log2n,deep[],n,m,s,ne; ...
- DFS/并查集 Codeforces Round #286 (Div. 2) B - Mr. Kitayuta's Colorful Graph
题目传送门 /* 题意:两点之间有不同颜色的线连通,问两点间单一颜色连通的路径有几条 DFS:暴力每个颜色,以u走到v为结束标志,累加条数 注意:无向图 */ #include <cstdio& ...
- import和from .xxx import *的一点重要区别
import zzz 不会导入zzz中已导入的模块 from .xxx import * 会导入xxx中已导入的模块 特别注意: 使用logging时,x模块导入了log.py,y模块导入了log.p ...
- IIS6配置FastCGI遇到ERROR5的解决方法
FastCGI Error The FastCGI Handler was unable to process the request. ------------------------------- ...