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= ...
随机推荐
- ios::sync_with_stdio(false);
取消cin与stdin的同步,加快输入速度
- 阿里云RDS数据库备份文件恢复到本地mysql数据库
一.安装mysql和xtrabackup (1)安装mysql 因为RDS是5.6版本,所以我们本地的mysql数据库要与RDS版本对应. rpm -ivh http://repo.mysql.co ...
- django上课笔记2-视图CBV-ORM补充-Django的自带分页-Django的自定义分页
一.视图CBV 1.urls url(r'^login.html$', views.Login.as_view()), 2.views from django.views import View cl ...
- (水题)洛谷 - P1579 - 哥德巴赫猜想(升级版)
https://www.luogu.org/problemnew/show/P1579 先预处理出素数看看有多少个,大概才2500个不到(事实上素数的个数大约是 $\frac{n}{ln(n)}$ ) ...
- POJ3258【二分】
题意: 问一个河岸,两岸之间有笔直的n块石头,然后拔起(也可以施展魔法)m个石块,假设两岸也是石块,求处理过的石块的最小距离的最大. 思路: 他让我们求移开m个石块,无非是在n+2-m(已经把两岸看成 ...
- python __builtins__ zip类 (71)
71.'zip' , 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表.如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作 ...
- NOIp2017真题模拟赛 By cellur925
果然我还是最菜的==不接受反驳 (先考了day2喵喵喵) Day2 T1:奶酪 期望得分:100分 实际得分:100分 考察:并查集 思路:这题其实之前做过了==.思路还是比较清晰的,读入时预处理出可 ...
- jQuery同时监听两个事件---实现同时操控两个按键
我们都知道因为js是单线程的,所以没有可以同时触发键盘两个事件的方法 今天我们就来做一个可以实现这个功能方法 先来看一下成品图效果 接下来我们来看下具体是怎么实现的 注释写在了代码里面 <!DO ...
- hdu 3461 Code Lock 并查集(有点难想到)★★
#include<stdio.h> #include<math.h> ]; int count; #define mod 1000000007 int find(int x) ...
- MVC 感触
这几天接触了下 ef+ MVC+WEBAPI +bootstrop VIEW--->Controller -->WebAPI ---Model (Linq) 记住 VIEW里的 csh ...