Fork me on GitHub

Nginx知识梳理-部署

官网文档

Installation on Linux

使用稳定版本的预构建包

环境介绍

1
2
3
4
5
6
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# uname -r
3.10.0-327.el7.x86_64
# uname -m
x86_64

添加源文件

1
2
3
4
5
6
7
8
9
cat >/etc/yum.repos.d/nginx.repo<<EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
EOF
sed -i 's/OS/centos/g' nginx.repo # 根据系统类型替换为rhel或centos
sed -i 's/OSRELEASE/7/g' nginx.repo # 根据系统版本替换为6或者7

部署

1
2
3
4
5
# yum install -y nginx
# systemctl start nginx
# systemctl enable nginx
# netstat -tunlp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2683/nginx: master

Building from Sources

下载

官网下载,选择nginx-1.12.2版本
官网参数讲解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
# tar -zxf pcre-8.41.tar.gz
# wget http://zlib.net/zlib-1.2.11.tar.xz
# xz -d zlib-1.2.11.tar.xz
# tar -xf zlib-1.2.11.tar
# wget http://nginx.org/download/nginx-1.12.2.tar.gz
# tar -zxf nginx-1.12.2.tar.gz
# cd nginx-1.12.2/
# tree -L 1
.
├── auto
├── CHANGES
├── CHANGES.ru
├── conf
├── configure
├── contrib
├── html
├── LICENSE
├── man
├── README
└── src
# cd nginx-1.12.2/
# ./configure
--sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-http_ssl_module
--with-pcre=../pcre-8.41
--with-zlib=../zlib-1.2.11
# make
# make install
# tree
.
├── client_body_temp
├── fastcgi.conf
├── fastcgi.conf.default
├── fastcgi_params
├── fastcgi_params.default
├── fastcgi_temp
├── html
│   ├── 50x.html
│   └── index.html
├── koi-utf
├── koi-win
├── logs
│   ├── access.log
│   └── error.log
├── mime.types
├── mime.types.default
├── nginx
├── nginx.conf
├── nginx.conf.default
├── nginx.pid
├── proxy_temp
├── scgi_params
├── scgi_params.default
├── scgi_temp
├── uwsgi_params
├── uwsgi_params.default
├── uwsgi_temp
└── win-utf

#

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/2589ba06.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!