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= ...
随机推荐
- Centos6.6安装后一些常见问题详解
<一>.centos6.6通过VM最小化安装后上不了网的解决方法: 在安装centos6.6时,没有在网络设置中设置网卡自动启动的,安装完系统后,是不能联网的,解决方法如下: vi/etc ...
- 【旧文章搬运】如何从EPROCESS辨别一个进程是否已退出
原文发表于百度空间,2008-7-31========================================================================== 前面已经通过 ...
- POI2013 Bytecomputer
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3427 可以证明最终序列为-1...0....1 因为首先如果 a(i-1) 为-1或0,执行操 ...
- 从ao神处偷取的头文件
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long lo ...
- Moctf--unset
今天完成了一道Moctf的代码审计题目.这道题目也花了我一定时间去搞清楚他的逻辑,所以把所学所想记录在此,并分享给需要的朋友. 打开题目后直接放出源码---> 之后就是疯狂百度这些函数的意思并努 ...
- hdoj5698
果然以前不想搞的东西,今天他妈全来了,我要爆炸,除了说操....真是欲哭无泪啊..... //这道题目卡在逆元了.... //利用逆元计算1/(n!(m-n)!) //对于正整数a,m如果有ax≡1( ...
- IT兄弟连 JavaWeb教程 使用Java同步机制对多线程同步
对于前面AdderServlet案例,它的sum实例变量用来累计客户端请求进行加法运算的和.sum变量的初始为100,如果第一个客户请求加上100,那么sum变量变为200,接着第二个客户请求加上20 ...
- python 之 random 模块、 shutil 模块、shelve模块、 xml模块
6.12 random 模块 print(random.random()) (0,1)----float 大于0且小于1之间的小数 print(random.randint(1,3)) [1,3] 大 ...
- Python基础:一起来面向对象 (二) 之搜索引擎
实例 搜索引擎 一个搜索引擎由搜索器.索引器.检索器和用户接口四个部分组成 搜索器就是爬虫(scrawler),爬出的内容送给索引器生成索引(Index)存储在内部数据库.用户通过用户接口发出询问(q ...
- 黑客攻防技术宝典web实战篇:查找源代码中的漏洞习题
猫宁!!! 参考链接:http://www.ituring.com.cn/book/885 随书答案. 1. 列出 3 种可在源代码中找到明确签名的常见漏洞. (a) 跨站点脚本(b) SQL 注入( ...