下载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 的编译安装及基本操作的更多相关文章

  1. Nginx 的编译安装和URL地址重写

    本文转自:http://www.178linux.com/14119#rd?sukey=ecafc0a7cc4a741b573a095a3eb78af6b4c9116b74d0bbc9844d8fc5 ...

  2. nginx应用编译安装

    nginx应用编译安装: 安装编译所需依赖包: # apt-get install make gcc g++ libcurl3-openssl-dev libfreetype6-dev libmcry ...

  3. nginx的编译安装以及启动脚本编写

    Nginx的编译安装和启动脚本的编写 Nginxd的功能强大,可以实现代理.负载均衡等企业常用的功能.下面介绍一下nginx的编译安装方法: 1. 下载 官方下载地址:http://nginx.org ...

  4. 初识Nginx及编译安装Nginx

    初识Nginx及编译安装Nginx 环境说明: 系统版本    CentOS 6.9 x86_64 软件版本    nginx-1.12.2 1.什么是Nginx? 如果你听说或使用过Apache软件 ...

  5. 【01】Nginx:编译安装/动态添加模块

    写在前面的话 说起 Nginx,别说运维,就是很多开发人员也很熟悉,毕竟如今已经 2019 年了,Apache 更多的要么成为了历史,要么成为了历史残留. 我们在提及 Nginx 的时候,一直在强调他 ...

  6. 【nginx运维基础(1)】Nginx的编译安装与使用

    nginx的官方手册: http://nginx.org/en/docs/ 编译安装 下载地址: http://nginx.org/en/download.html # 为了支持rewrite功能,我 ...

  7. Nginx服务编译安装、日志功能、状态模块及访问认证模式实操

    系统环境 [root@web ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@web ~]# uname -a Linux d ...

  8. Nginx的编译安装及选项

    编译安装Nginx1.安装常见的工具和库(GCC.PCRE.zlib.OpenSSL) Nginx是一个由C语言编写的,所以需要一个编译工具如GNU的GCC[root@www ~]# yum inst ...

  9. Nginx之编译安装的nginx加入systemctl

    编译安装的nginx需要添加rc.local 编译安装后设置 /usr/lib/systemd/system/nginx.service [Unit] Description=nginx After= ...

随机推荐

  1. 交通规划_dijkstra

    问题描述 G国国王来中国参观后,被中国的高速铁路深深的震撼,决定为自己的国家也建设一个高速铁路系统. 建设高速铁路投入非常大,为了节约建设成本,G国国王决定不新建铁路,而是将已有的铁路改造成高速铁路. ...

  2. Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)(转载)

    转自:http://www.cnblogs.com/salam/archive/2010/11/30/1892143.html 我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其 ...

  3. C++笔试题库之编程、问答题 150~200道

    151.写出判断ABCD四个表达式的是否正确, 若正确, 写出经过表达式中 a的值 int a = 4; (A)a += (a++); (B) a += (++a) ;(C) (a++) += a;( ...

  4. Codeforces 快速竞技#4

    快速竞技#4 A–Duff and Meat588A = =这题不知道怎么写题解了.. 直接上code---. #include<bits/stdc++.h> #include<st ...

  5. HDU1016【简单递归.DFS】

    题意:一个环,相邻相加是素数. 思路: 直接深搜就好了.. output limit exceed 了好几发... 因为那个while里面的scanf前面的"~" 后来搜了outp ...

  6. P5162 WD与积木(多项式求逆+生成函数)

    传送门 题解 比赛的时候光顾着算某一个\(n\)的答案是多少忘了考虑不同的\(n\)之间的联系了--而且我也很想知道为什么推着推着会变成一个二项式反演-- 设\(f_n\)为\(n\)块积木时的总的层 ...

  7. mui中一级联动

    <!doctype html><html> <head> <meta charset="utf-8"> <title>& ...

  8. PJzhang:centos7动态IP和静态IP两种方式的设置

    猫宁!!! 参考链接:https://blog.csdn.net/m0_37776094/article/details/81736900 如果centos7只设置静态IP,对于不断切换无线网的情况并 ...

  9. The local variable fruit may not have been initialized 错误

    eclipse错误提示如图: 错误代码如图: 首先这错误的翻译是:局部变量"水果"尚未初始化,所以对象该如何初始化呢,我百度之后找到了答案,修改过后如下图所示. 这个错误的问题所在 ...

  10. Retrofit实现PUT网络请求,并修改Content-Type

    @FormUrlEncoded @PUT(Constant.BOSS_HX_CHANGE_PHONE_INTERVIEW) Call<ResponseHxResultBean> handl ...