-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx安装和编译.htm
403 lines (371 loc) · 61.1 KB
/
nginx安装和编译.htm
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Nginx安装和编译 | Anthony's Blog</title><meta name="keywords" content="Linux,Service,Nginx"><meta name="author" content="HaoDong Wu"><meta name="copyright" content="HaoDong Wu"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Centos7通过yum或者手动编译安装Nginx以及Nginx各种模块介绍">
<meta property="og:type" content="article">
<meta property="og:title" content="Nginx安装和编译">
<meta property="og:url" content="https://www.scery.com/nginx%E5%AE%89%E8%A3%85%E5%92%8C%E7%BC%96%E8%AF%91.htm">
<meta property="og:site_name" content="Anthony's Blog">
<meta property="og:description" content="Centos7通过yum或者手动编译安装Nginx以及Nginx各种模块介绍">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
<meta property="article:published_time" content="2019-02-20T00:19:33.000Z">
<meta property="article:modified_time" content="2019-02-20T13:33:58.000Z">
<meta property="article:author" content="HaoDong Wu">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="Service">
<meta property="article:tag" content="Nginx">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"><link rel="shortcut icon" href="/img/avatar.png"><link rel="canonical" href="https://www.scery.com/nginx%E5%AE%89%E8%A3%85%E5%92%8C%E7%BC%96%E8%AF%91.htm"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="baidu-site-verification" content="code-cOpY18SESu"/><link rel="stylesheet" href="css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
root: '/',
algolia: undefined,
localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容:${query}"}},
translate: undefined,
noticeOutdate: undefined,
highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
copy: {
success: '复制成功',
error: '复制错误',
noSupport: '浏览器不支持'
},
relativeDate: {
homepage: false,
post: false
},
runtime: '天',
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
copyright: undefined,
lightbox: 'fancybox',
Snackbar: undefined,
source: {
justifiedGallery: {
js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
}
},
isPhotoFigcaption: false,
islazyload: false,
isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
title: 'Nginx安装和编译',
isPost: true,
isHome: false,
isHighlightShrink: false,
isToc: true,
postUpdate: '2019-02-20 21:33:58'
}</script><noscript><style type="text/css">
#nav {
opacity: 1
}
.justified-gallery img {
opacity: 1
}
#recent-posts time,
#post-meta time {
display: inline !important
}
</style></noscript><script>(win=>{
win.saveToLocal = {
set: function setWithExpiry(key, value, ttl) {
if (ttl === 0) return
const now = new Date()
const expiryDay = ttl * 86400000
const item = {
value: value,
expiry: now.getTime() + expiryDay,
}
localStorage.setItem(key, JSON.stringify(item))
},
get: function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
if (!itemStr) {
return undefined
}
const item = JSON.parse(itemStr)
const now = new Date()
if (now.getTime() > item.expiry) {
localStorage.removeItem(key)
return undefined
}
return item.value
}
}
win.getScript = url => new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = url
script.async = true
script.onerror = reject
script.onload = script.onreadystatechange = function() {
const loadState = this.readyState
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
script.onload = script.onreadystatechange = null
resolve()
}
document.head.appendChild(script)
})
win.activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
}
}
win.activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
}
}
const t = saveToLocal.get('theme')
if (t === 'dark') activateDarkMode()
else if (t === 'light') activateLightMode()
const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
if (asideStatus === 'hide') {
document.documentElement.classList.add('hide-aside')
} else {
document.documentElement.classList.remove('hide-aside')
}
}
const detectApple = () => {
if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
document.documentElement.classList.add('apple')
}
}
detectApple()
})(window)</script><meta name="generator" content="Hexo 5.4.2"><link rel="alternate" href="atom.xml" title="Anthony's Blog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="../img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="../archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="../tags/"><div class="headline">标签</div><div class="length-num">58</div></a><a href="/"><div class="headline">分类</div><div class="length-num">61</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="../index.html"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="../archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="../tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="../categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="../links/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="../about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')"><nav id="nav"><span id="blog_name"><a id="site-name" href="../index.html">Anthony's Blog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="../index.html"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="../archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="../tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="../categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="../links/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="../about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Nginx安装和编译</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-02-20T00:19:33.000Z" title="发表于 2019-02-20 08:19:33">2019-02-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2019-02-20T13:33:58.000Z" title="更新于 2019-02-20 21:33:58">2019-02-20</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/Linux/">Linux</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/Linux/Service/">Service</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/Linux/Service/Nginx/">Nginx</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/Linux/Service/Nginx/Sortware/">Sortware</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">4.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>17分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Nginx安装和编译"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Nginx安装和编译"><a href="#Nginx安装和编译" class="headerlink" title="Nginx安装和编译"></a>Nginx安装和编译</h1><h2 id="yum源安装"><a href="#yum源安装" class="headerlink" title="yum源安装"></a>yum源安装</h2><figure class="highlight awk"><table><tr><td class="code"><pre><span class="line">yum -y install gcc gcc-c++ autoconf automake make</span><br><span class="line"></span><br><span class="line">yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel</span><br><span class="line"></span><br><span class="line">sudo rpm -Uvh http:<span class="regexp">//</span>nginx.org<span class="regexp">/packages/</span>centos<span class="regexp">/7/</span>noarch<span class="regexp">/RPMS/</span>nginx-release-centos-<span class="number">7</span>-<span class="number">0</span>.el7.ngx.noarch.rpm</span><br><span class="line"></span><br><span class="line">yum install -y nginx</span><br></pre></td></tr></table></figure>
<figure class="highlight nsis"><table><tr><td class="code"><pre><span class="line"><span class="params">system</span>ctl start nginx.service</span><br><span class="line"><span class="params">system</span>ctl enable nginx.service</span><br></pre></td></tr></table></figure>
<h2 id="编译安装"><a href="#编译安装" class="headerlink" title="编译安装"></a>编译安装</h2><figure class="highlight awk"><table><tr><td class="code"><pre><span class="line">yum -y install gcc gcc-c++ autoconf automake make </span><br><span class="line">yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel</span><br><span class="line">groupadd -f nginx</span><br><span class="line">useradd -g nginx nginx</span><br><span class="line">wget https:<span class="regexp">//</span>nginx.org<span class="regexp">/download/</span>nginx-<span class="number">1.19</span>.<span class="number">0</span>.tar.gz</span><br><span class="line"><span class="comment">#下载官网 https://nginx.org/en/download.html</span></span><br><span class="line">wget https:<span class="regexp">//gi</span>thub.com<span class="regexp">/openssl/</span>openssl<span class="regexp">/archive/</span>OpenSSL_1_1_1h.tar.gz</span><br><span class="line"><span class="comment">#openssl源码下载 https://github.com/openssl/openssl/releases</span></span><br></pre></td></tr></table></figure>
<p>先更新openssl</p>
<p>进入openssl源码目录</p>
<figure class="highlight gradle"><table><tr><td class="code"><pre><span class="line">yum -y install perl perl-devel gcc gcc-c++</span><br><span class="line">./config shared zlib</span><br><span class="line">make && make install</span><br><span class="line">mv <span class="regexp">/usr/</span>bin<span class="regexp">/openssl /u</span>sr<span class="regexp">/bin/</span>openssl.bak</span><br><span class="line">mv <span class="regexp">/usr/i</span>nclude<span class="regexp">/openssl /u</span>sr<span class="regexp">/include/</span>openssl.bak</span><br><span class="line"><span class="keyword">find</span> / -name openssl</span><br><span class="line">ln -s <span class="regexp">/usr/</span>local<span class="regexp">/bin/</span>openssl <span class="regexp">/usr/</span>bin/openssl</span><br><span class="line">ln -s <span class="regexp">/usr/</span>local<span class="regexp">/include/</span>openssl <span class="regexp">/usr/i</span>nclude/openssl</span><br><span class="line">echo <span class="string">"/usr/local/lib64/"</span> >> <span class="regexp">/etc/</span>ld.so.conf</span><br><span class="line">ldconfig</span><br><span class="line">openssl version -a</span><br><span class="line">openssl version</span><br></pre></td></tr></table></figure>
<p>解压了nginx源码之后</p>
<p>进入到nginx源码目录</p>
<figure class="highlight awk"><table><tr><td class="code"><pre><span class="line"><span class="regexp">//</span>新增加stream 和 pressl支持编译</span><br><span class="line">.<span class="regexp">/configure --user=nginx --group=nginx --prefix=/</span>nginx_main --sbin-path=<span class="regexp">/usr/</span>sbin<span class="regexp">/nginx --conf-path=/</span>etc<span class="regexp">/nginx/</span>nginx.conf --http-log-path=<span class="regexp">/nginx/</span>log<span class="regexp">/access.log --error-log-path=/</span>nginx<span class="regexp">/log/</span>error.log --lock-path=<span class="regexp">/var/</span>lock<span class="regexp">/nginx.lock --pid-path=/</span>run<span class="regexp">/nginx.pid --modules-path=/u</span>sr<span class="regexp">/lib/</span>nginx<span class="regexp">/modules --http-client-body-temp-path=/</span>var<span class="regexp">/lib/</span>nginx<span class="regexp">/body --http-fastcgi-temp-path=/</span>var<span class="regexp">/lib/</span>nginx<span class="regexp">/fastcgi --http-proxy-temp-path=/</span>var<span class="regexp">/lib/</span>nginx<span class="regexp">/proxy --http-scgi-temp-path=/</span>var<span class="regexp">/lib/</span>nginx<span class="regexp">/scgi --http-uwsgi-temp-path=/</span>var<span class="regexp">/lib/</span>nginx<span class="regexp">/uwsgi --with-openssl=/</span>root<span class="regexp">/install/</span>openssl-OpenSSL_1_1_1h --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-stream --with-http_sub_module --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-stream_ssl_preread_module --with-mail_ssl_module --with-cc-opt=<span class="string">'-g -O2 -Wp,-D_FORTIFY_SOURCE=2'</span></span><br></pre></td></tr></table></figure>
<figure class="highlight livescript"><table><tr><td class="code"><pre><span class="line">./configure <span class="string">\</span></span><br><span class="line">--user=nginx <span class="string">\</span></span><br><span class="line">--group=nginx <span class="string">\</span></span><br><span class="line">--prefix=/nginx_main <span class="string">\</span></span><br><span class="line">--sbin-path=/usr/sbin/nginx <span class="string">\</span></span><br><span class="line">--conf-path=/etc/nginx/nginx.conf <span class="string">\</span></span><br><span class="line">--http-log-path=/nginx/log/access.log <span class="string">\</span></span><br><span class="line">--error-log-path=/nginx/log/error.log <span class="string">\</span></span><br><span class="line">--lock-path=/<span class="keyword">var</span>/lock/nginx.lock <span class="string">\</span></span><br><span class="line">--pid-path=/run/nginx.pid <span class="string">\</span></span><br><span class="line">--modules-path=/usr/lib/nginx/modules <span class="string">\</span></span><br><span class="line">--http-client-body-temp-path=/<span class="keyword">var</span>/lib/nginx/body <span class="string">\</span></span><br><span class="line">--http-fastcgi-temp-path=/<span class="keyword">var</span>/lib/nginx/fastcgi <span class="string">\</span></span><br><span class="line">--http-proxy-temp-path=/<span class="keyword">var</span>/lib/nginx/proxy <span class="string">\</span></span><br><span class="line">--http-scgi-temp-path=/<span class="keyword">var</span>/lib/nginx/scgi <span class="string">\</span></span><br><span class="line">--http-uwsgi-temp-path=/<span class="keyword">var</span>/lib/nginx/uwsgi <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-openssl=/root/openssl-<span class="number">1.1</span>.<span class="number">1g</span> <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-pcre-jit <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_ssl_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_stub_status_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_realip_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_auth_request_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_v2_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_dav_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_slice_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-threads <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_addition_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_gunzip_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_gzip_static_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-http_sub_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-stream <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-stream=dynamic <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-stream_ssl_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-mail=dynamic <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-stream_ssl_preread_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-mail_ssl_module <span class="string">\</span></span><br><span class="line">--<span class="keyword">with</span>-cc-opt=<span class="string">'-g -O2 -Wp,-D_FORTIFY_SOURCE=2'</span></span><br></pre></td></tr></table></figure>
<figure class="highlight gauss"><table><tr><td class="code"><pre><span class="line"><span class="built_in">make</span> && <span class="built_in">make</span> install</span><br></pre></td></tr></table></figure>
<p>如果需要修改响应头的信息:</p>
<figure class="highlight gradle"><table><tr><td class="code"><pre><span class="line">修改server要在编译Nginx修改<span class="regexp">/src/</span>core/nginx.h文件</span><br><span class="line"></span><br><span class="line">#define NGINX_VERSION <span class="string">"1.14"</span> </span><br><span class="line">#define NGINX_VER <span class="string">"nginx"</span> </span><br><span class="line"></span><br><span class="line"><span class="number">2</span>: 修改src<span class="regexp">/http/</span>ngx_http_header_filter_module.c</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">char</span> ngx_http_server_string[]=<span class="string">"Server: nginx"</span> CRLF;</span><br><span class="line"><span class="number">3</span>: 修改src<span class="regexp">/http/</span>ngx_http_special_response.c</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> u_char ngx_http_error_tail[]=<span class="string">"<hr><center>nginx</center>"</span> CRLF</span><br></pre></td></tr></table></figure>
<p>(macOS nginx 配置文件目录/usr/local/etc/nginx)</p>
<p>nginx命令</p>
<figure class="highlight jboss-cli"><table><tr><td class="code"><pre><span class="line">nginx -s reopen <span class="comment">#重启Nginx</span></span><br><span class="line"></span><br><span class="line">nginx -s <span class="keyword">reload</span> <span class="comment">#重新加载Nginx配置文件,然后以优雅的方式重启Nginx</span></span><br><span class="line"></span><br><span class="line">nginx -s stop <span class="comment">#强制停止Nginx服务</span></span><br><span class="line"></span><br><span class="line">nginx -s <span class="keyword">quit</span> <span class="comment">#优雅地停止Nginx服务(即处理完所有请求后再停止服务)</span></span><br><span class="line"></span><br><span class="line">nginx -t <span class="comment">#检测配置文件是否有语法错误,然后退出</span></span><br><span class="line"></span><br><span class="line">nginx -?,-h <span class="comment">#打开帮助信息</span></span><br><span class="line"></span><br><span class="line">nginx -v <span class="comment">#显示版本信息并退出</span></span><br><span class="line"></span><br><span class="line">nginx -V <span class="comment">#显示版本和配置选项信息,然后退出</span></span><br><span class="line"></span><br><span class="line">nginx -t <span class="comment">#检测配置文件是否有语法错误,然后退出</span></span><br><span class="line"></span><br><span class="line">nginx -T <span class="comment">#检测配置文件是否有语法错误,转储并退出</span></span><br><span class="line"></span><br><span class="line">nginx -q <span class="comment">#在检测配置文件期间屏蔽非错误信息</span></span><br><span class="line"></span><br><span class="line">nginx -p prefix <span class="comment">#设置前缀路径(默认是:/usr/share/nginx/)</span></span><br><span class="line"></span><br><span class="line">nginx -c filename <span class="comment">#设置配置文件(默认是:/etc/nginx/nginx.conf)</span></span><br><span class="line"></span><br><span class="line">nginx -g directives <span class="comment">#设置配置文件外的全局指令</span></span><br><span class="line"></span><br><span class="line">killall nginx <span class="comment">#杀死所有nginx进程</span></span><br></pre></td></tr></table></figure>
<p>nginx开机自启配置</p>
<p>vi /usr/lib/systemd/system/nginx.service</p>
<figure class="highlight ini"><table><tr><td class="code"><pre><span class="line"><span class="section">[Unit]</span></span><br><span class="line"><span class="attr">Description</span>=nginx</span><br><span class="line"><span class="attr">After</span>=network.target</span><br><span class="line"> </span><br><span class="line"><span class="section">[Service]</span></span><br><span class="line"><span class="attr">Type</span>=forking</span><br><span class="line"><span class="attr">ExecStart</span>=/usr/sbin/nginx</span><br><span class="line"><span class="attr">ExecReload</span>=/usr/sbin/nginx -s reload</span><br><span class="line"><span class="attr">ExecStop</span>=/usr/sbin/nginx -s quit</span><br><span class="line"><span class="attr">PrivateTmp</span>=<span class="literal">true</span></span><br><span class="line"> </span><br><span class="line"><span class="section">[Install]</span></span><br><span class="line"><span class="attr">WantedBy</span>=multi-user.target</span><br></pre></td></tr></table></figure>
<figure class="highlight nsis"><table><tr><td class="code"><pre><span class="line"><span class="params">system</span>ctl enable nginx.service</span><br><span class="line"><span class="params">system</span>ctl start nginx.service</span><br></pre></td></tr></table></figure>
<p>手动编译的模块信息:</p>
<p>–help</p>
<pre><code>打印帮助信息。</code></pre><p>–prefix=path</p>
<pre><code>定义将保留服务器文件的目录。此相同目录还将用于设置的所有相对路径 configure(库源路径除外)和nginx.conf配置文件中。/usr/local/nginx默认情况下设置为目录。</code></pre><p>–sbin-path=path</p>
<pre><code>设置nginx可执行文件的名称。此名称仅在安装期间使用。默认情况下,文件名为 prefix/sbin/nginx。</code></pre><p>–modules-path=path</p>
<pre><code>定义将在其中安装nginx动态模块的目录。默认情况下使用prefix/modules目录。</code></pre><p>–conf-path=path</p>
<pre><code>设置nginx.conf配置文件的名称。如果需要,可以通过在命令行参数中指定nginx来始终使用其他配置文件来启动它 。默认情况下,文件名为 。 -c fileprefix/conf/nginx.conf</code></pre><p>–error-log-path=path</p>
<pre><code>设置主要错误,警告和诊断文件的名称。安装后,可以始终nginx.conf使用error_log伪指令在配置文件中 更改文件名 。默认情况下,文件名为 prefix/logs/error.log。</code></pre><p>–pid-path=path</p>
<pre><code>设置nginx.pid将存储主进程的进程ID 的文件名。安装后,可以始终nginx.conf使用pid伪指令在配置文件中 更改文件名 。默认情况下,文件名为 prefix/logs/nginx.pid。</code></pre><p>–lock-path=path</p>
<pre><code>为锁定文件的名称设置前缀。安装后,可以始终nginx.conf使用lock_file伪指令在配置文件中 更改该值 。默认情况下,值为 prefix/logs/nginx.lock。</code></pre><p>–user=name</p>
<pre><code>设置一个非特权用户的名称,其凭据将由工作进程使用。安装后,可以始终nginx.conf使用用户指令在配置文件中 更改名称 。默认用户名是nobody。</code></pre><p>–group=name</p>
<pre><code>设置其凭据将由工作进程使用的组的名称。安装后,可以始终nginx.conf使用用户指令在配置文件中 更改名称 。默认情况下,组名称设置为非特权用户的名称。</code></pre><p>–build=name</p>
<pre><code>设置一个可选的nginx构建名称。</code></pre><p>–builddir=path</p>
<pre><code>设置构建目录。</code></pre><p>–with-select_module 和 –without-select_module</p>
<pre><code>启用或禁用构建允许服务器使用该select()方法的模块。如果平台似乎不支持kqueue,epoll或/ dev / poll等更合适的方法,则会自动构建此模块。</code></pre><p>–with-poll_module 和 –without-poll_module</p>
<pre><code>启用或禁用构建允许服务器使用该poll()方法的模块。如果平台似乎不支持kqueue,epoll或/ dev / poll等更合适的方法,则会自动构建此模块。</code></pre><p>–with-threads</p>
<pre><code>启用线程池的使用 。</code></pre><p>–with-file-aio</p>
<pre><code>支持 在FreeBSD和Linux上使用 异步文件I / O(AIO)。</code></pre><p>–with-http_ssl_module</p>
<pre><code>启用构建将HTTPS协议支持添加 到HTTP服务器的模块的功能。默认情况下未构建此模块。需要OpenSSL库来构建和运行此模块。</code></pre><p>–with-http_v2_module</p>
<pre><code>支持构建一个模块,该模块提供对HTTP / 2的支持 。默认情况下未构建此模块。</code></pre><p>–with-http_realip_module</p>
<pre><code>支持构建ngx_http_realip_module 模块,该 模块将客户端地址更改为在指定的标头字段中发送的地址。默认情况下未构建此模块。</code></pre><p>–with-http_addition_module</p>
<pre><code>允许构建ngx_http_addition_module 模块,该 模块在响应之前和之后添加文本。默认情况下未构建此模块。</code></pre><p>–with-http_xslt_module 和 –with-http_xslt_module=dynamic</p>
<pre><code>支持构建ngx_http_xslt_module 模块,该 模块使用一个或多个XSLT样式表转换XML响应。默认情况下未构建此模块。该libxml2的和 的libxslt库需要构建和运行此模块。</code></pre><p>–with-http_image_filter_module 和 –with-http_image_filter_module=dynamic</p>
<pre><code>支持构建ngx_http_image_filter_module 模块,该 模块可以转换JPEG,GIF,PNG和WebP格式的图像。默认情况下未构建此模块。</code></pre><p>–with-http_geoip_module 和 –with-http_geoip_module=dynamic</p>
<pre><code>支持构建ngx_http_geoip_module 模块,该 模块根据客户端IP地址和预编译的MaxMind数据库创建变量 。默认情况下未构建此模块。</code></pre><p>–with-http_sub_module</p>
<pre><code>支持构建ngx_http_sub_module 模块,该 模块通过将一个指定的字符串替换为另一个指定的字符串来修改响应。默认情况下未构建此模块。</code></pre><p>–with-http_dav_module</p>
<pre><code>支持构建ngx_http_dav_module 模块,该 模块通过WebDAV协议提供文件管理自动化。默认情况下未构建此模块。</code></pre><p>–with-http_flv_module</p>
<pre><code>支持构建ngx_http_flv_module 模块,该 模块为Flash Video(FLV)文件提供伪流服务器端支持。默认情况下未构建此模块。</code></pre><p>–with-http_mp4_module </p>
<figure class="highlight gcode"><table><tr><td class="code"><pre><span class="line">支持构建<span class="symbol">ngx_http_mp4</span>_module 模块,该 模块为MP<span class="number">4</span>文件提供伪流服务器端支持。默认情况下未构建此模块。</span><br></pre></td></tr></table></figure>
<p>–with-http_gunzip_module</p>
<pre><code>支持为不支持“ gzip”编码方法的客户端构建ngx_http_gunzip_module 模块,该 模块使用“ Content-Encoding: gzip” 解压缩响应。默认情况下未构建此模块。</code></pre><p>–with-http_gzip_static_module</p>
<pre><code>支持构建ngx_http_gzip_static_module 模块,该 模块支持发送.gz扩展名为“ ”的预压缩文件,而不是常规文件。默认情况下未构建此模块。</code></pre><p>–with-http_auth_request_module</p>
<pre><code>允许构建ngx_http_auth_request_module 模块,该 模块基于子请求的结果实现客户端授权。默认情况下未构建此模块。</code></pre><p>–with-http_random_index_module</p>
<pre><code>支持构建ngx_http_random_index_module 模块,该 模块处理以斜杠(' /')结尾的请求,并从目录中选择一个随机文件作为索引文件。默认情况下未构建此模块。</code></pre><p>–with-http_secure_link_module</p>
<pre><code>启用构建 ngx_http_secure_link_module 模块。默认情况下未构建此模块。</code></pre><p>–with-http_degradation_module</p>
<pre><code>启用构建 ngx_http_degradation_module模块。默认情况下未构建此模块。</code></pre><p>–with-http_slice_module</p>
<pre><code>支持构建ngx_http_slice_module 模块,该 模块将请求拆分为子请求,每个子请求返回一定范围的响应。该模块提供了更有效的大响应缓存。默认情况下未构建此模块。</code></pre><p>–with-http_stub_status_module</p>
<pre><code>支持构建ngx_http_stub_status_module 模块,该 模块提供对基本状态信息的访问。默认情况下未构建此模块。</code></pre><p>–without-http_charset_module</p>
<pre><code>禁用构建ngx_http_charset_module 模块,该 模块将指定的字符集添加到“ Content-Type”响应头字段中,并且可以将数据从一个字符集转换为另一个字符集。</code></pre><p>–without-http_gzip_module</p>
<pre><code>禁用构建可压缩 HTTP服务器响应的模块。zlib库是构建和运行此模块所必需的。</code></pre><p>–without-http_ssi_module</p>
<pre><code>禁用构建 处理通过SSI(服务器端包含)命令的 ngx_http_ssi_module模块的响应。</code></pre><p>–without-http_userid_module</p>
<pre><code>禁用构建ngx_http_userid_module 模块,该 模块设置适用于客户端标识的cookie。</code></pre><p>–without-http_access_module</p>
<pre><code>禁用构建ngx_http_access_module 模块,该 模块允许限制对某些客户端地址的访问。</code></pre><p>–without-http_auth_basic_module</p>
<pre><code>禁用构建ngx_http_auth_basic_module 模块,该 模块允许通过使用“ HTTP基本身份验证”协议验证用户名和密码来限制对资源的访问。</code></pre><p>–without-http_mirror_module</p>
<pre><code>禁用构建ngx_http_mirror_module 模块,该 模块通过创建后台镜像子请求来实现原始请求的镜像。</code></pre><p>–without-http_autoindex_module</p>
<pre><code>禁用构建 ngx_http_autoindex_module 模块,以处理以斜杠(' /')结尾的请求,并在ngx_http_index_module模块找不到索引文件的情况下生成目录列表 。</code></pre><p>–without-http_geo_module</p>
<pre><code>禁用构建ngx_http_geo_module 模块,该 模块创建的变量的值取决于客户端IP地址。</code></pre><p>–without-http_map_module</p>
<pre><code>禁用构建ngx_http_map_module 模块,该 模块创建的变量的值取决于其他变量的值。</code></pre><p>–without-http_split_clients_module</p>
<pre><code>禁用构建ngx_http_split_clients_module 模块,该 模块创建用于A / B测试的变量。</code></pre><p>–without-http_referer_module</p>
<pre><code>禁用构建ngx_http_referer_module 模块,该 模块可以阻止对“ Referer”标头字段中具有无效值的请求的站点访问。</code></pre><p>–without-http_rewrite_module</p>
<pre><code>禁用构建允许HTTP服务器 重定向请求并更改请求URI的模块。构建和运行此模块需要PCRE库。</code></pre><p>–without-http_proxy_module</p>
<pre><code>禁用构建HTTP服务器 代理模块。</code></pre><p>–without-http_fastcgi_module</p>
<pre><code>禁用构建 将请求传递到FastCGI服务器的 ngx_http_fastcgi_module模块。</code></pre><p>–without-http_uwsgi_module</p>
<pre><code>禁用构建 将请求传递到uwsgi服务器的 ngx_http_uwsgi_module模块。</code></pre><p>–without-http_scgi_module</p>
<pre><code>禁用构建 将请求传递到SCGI服务器的 ngx_http_scgi_module模块。</code></pre><p>–without-http_grpc_module</p>
<pre><code>禁用构建 将请求传递到gRPC服务器的 ngx_http_grpc_module模块。</code></pre><p>–without-http_memcached_module</p>
<pre><code>禁用构建ngx_http_memcached_module 模块,该 模块从memcached服务器获取响应。</code></pre><p>–without-http_limit_conn_module</p>
<pre><code>禁用构建ngx_http_limit_conn_module 模块,该 模块限制每个键的连接数,例如,单个IP地址的连接数。</code></pre><p>–without-http_limit_req_module</p>
<pre><code>禁用构建ngx_http_limit_req_module 模块,该 模块限制每个密钥的请求处理速率,例如,来自单个IP地址的请求的处理速率。</code></pre><p>–without-http_empty_gif_module</p>
<pre><code>禁用构建发出单像素透明GIF的模块 。</code></pre><p>–without-http_browser_module</p>
<pre><code>禁用构建ngx_http_browser_module 模块,该 模块创建的变量的值取决于“ User-Agent”请求标头字段的值。</code></pre><p>–without-http_upstream_hash_module</p>
<pre><code>禁用构建实现哈希 负载平衡方法的模块 。</code></pre><p>–without-http_upstream_ip_hash_module</p>
<pre><code>禁用构建实现ip_hash 负载平衡方法的模块 。</code></pre><p>–without-http_upstream_least_conn_module</p>
<pre><code>禁用构建实现了minimum_conn 负载平衡方法的模块 。</code></pre><p>–without-http_upstream_keepalive_module</p>
<pre><code>禁用构建一个模块来提供 对上游服务器连接的缓存。</code></pre><p>–without-http_upstream_zone_module</p>
<pre><code>禁用构建模块,该模块可以将上游组的运行时状态存储在共享内存 区域中。</code></pre><p>–with-http_perl_module 和 –with-http_perl_module=dynamic</p>
<pre><code>支持构建 嵌入式Perl模块。默认情况下未构建此模块。</code></pre><p>–with-perl_modules_path=path</p>
<pre><code>定义一个目录,该目录将保留Perl模块。</code></pre><p>–with-perl=path</p>
<pre><code>设置Perl二进制文件的名称。</code></pre><p>–http-log-path=path</p>
<pre><code>设置HTTP服务器的主请求日志文件的名称。安装后,可以始终nginx.conf使用access_log伪指令在配置文件中 更改文件名 。默认情况下,文件名为 prefix/logs/access.log。</code></pre><p>–http-client-body-temp-path=path</p>
<pre><code>定义用于存储包含客户端请求正文的临时文件的目录。安装后,可以始终nginx.conf使用client_body_temp_path 指令在配置文件中 更改目录 。默认情况下,目录名为 prefix/client_body_temp。</code></pre><p>–http-proxy-temp-path=path</p>
<pre><code>定义一个目录,用于存储包含从代理服务器接收到的数据的临时文件。安装后,可以始终nginx.conf使用proxy_temp_path 指令在配置文件中 更改目录 。默认情况下,目录名为 prefix/proxy_temp。</code></pre><p>–http-fastcgi-temp-path=path</p>
<pre><code>定义一个目录,用于存储包含从FastCGI服务器接收到的数据的临时文件。安装后,可以始终nginx.conf使用fastcgi_temp_path 指令在配置文件中 更改目录 。默认情况下,目录名为 prefix/fastcgi_temp。</code></pre><p>–http-uwsgi-temp-path=path</p>
<pre><code>定义一个目录,用于存储带有从uwsgi服务器接收到的数据的临时文件。安装后,可以始终nginx.conf使用uwsgi_temp_path 指令在配置文件中 更改目录 。默认情况下,目录名为 prefix/uwsgi_temp。</code></pre><p>–http-scgi-temp-path=path</p>
<pre><code>定义一个目录,用于存储带有从SCGI服务器接收到的数据的临时文件。安装后,可以始终nginx.conf使用scgi_temp_path 指令在配置文件中 更改目录 。默认情况下,目录名为 prefix/scgi_temp。</code></pre><p>–without-http</p>
<pre><code>禁用HTTP服务器。</code></pre><p>–without-http-cache</p>
<pre><code>禁用HTTP缓存。</code></pre><p>–with-mail 和 –with-mail=dynamic</p>
<pre><code>启用POP3 / IMAP4 / SMTP 邮件代理服务器。</code></pre><p>–with-mail_ssl_module</p>
<pre><code>支持构建一个模块,该模块 向邮件代理服务器添加 SSL / TLS协议支持。默认情况下未构建此模块。需要OpenSSL库来构建和运行此模块。</code></pre><p>–without-mail_pop3_module</p>
<pre><code>在邮件代理服务器中 禁用POP3协议。</code></pre><p>–without-mail_imap_module</p>
<pre><code>在邮件代理服务器中 禁用IMAP协议。</code></pre><p>–without-mail_smtp_module</p>
<pre><code>在邮件代理服务器中 禁用SMTP协议。</code></pre><p>–with-stream 和 –with-stream=dynamic</p>
<pre><code>支持构建 用于通用TCP / UDP代理和负载平衡的 流模块。默认情况下未构建此模块。</code></pre><p>–with-stream_ssl_module</p>
<pre><code>支持构建一个模块,该模块 向流模块添加 SSL / TLS协议支持。默认情况下未构建此模块。需要OpenSSL库来构建和运行此模块。</code></pre><p>–with-stream_realip_module</p>
<pre><code>启用构建ngx_stream_realip_module 模块的功能,该 模块将客户端地址更改为PROXY协议标头中发送的地址。默认情况下未构建此模块。</code></pre><p>–with-stream_geoip_module 和 –with-stream_geoip_module=dynamic</p>
<pre><code>支持构建ngx_stream_geoip_module 模块,该 模块根据客户端IP地址和预编译的MaxMind数据库创建变量 。默认情况下未构建此模块。</code></pre><p>–with-stream_ssl_preread_module</p>
<pre><code>支持构建ngx_stream_ssl_preread_module 模块,该 模块允许从ClientHello 消息中提取信息, 而无需终止SSL / TLS。默认情况下未构建此模块。</code></pre><p>–without-stream_limit_conn_module</p>
<pre><code>禁用构建ngx_stream_limit_conn_module 模块,该 模块限制每个键的连接数,例如,单个IP地址的连接数。</code></pre><p>–without-stream_access_module</p>
<pre><code>禁用构建ngx_stream_access_module 模块,该 模块允许限制对某些客户端地址的访问。</code></pre><p>–without-stream_geo_module</p>
<pre><code>禁用构建ngx_stream_geo_module 模块,该 模块创建的变量值取决于客户端IP地址。</code></pre><p>–without-stream_map_module</p>
<pre><code>禁用构建ngx_stream_map_module 模块,该 模块创建的变量值取决于其他变量的值。</code></pre><p>–without-stream_split_clients_module</p>
<pre><code>禁用构建ngx_stream_split_clients_module 模块,该 模块创建用于A / B测试的变量。</code></pre><p>–without-stream_return_module</p>
<pre><code>禁用构建ngx_stream_return_module 模块,该 模块向客户端发送一些指定的值,然后关闭连接。</code></pre><p>–without-stream_upstream_hash_module</p>
<pre><code>禁用构建实现哈希 负载平衡方法的模块 。</code></pre><p>–without-stream_upstream_least_conn_module</p>
<pre><code>禁用构建实现了minimum_conn 负载平衡方法的模块 。</code></pre><p>–without-stream_upstream_zone_module</p>
<pre><code>禁用构建模块,该模块可以将上游组的运行时状态存储在共享内存 区域中。</code></pre><p>–with-google_perftools_module</p>
<pre><code>允许构建ngx_google_perftools_module 模块,该 模块可以使用Google Performance Tools对nginx工作进程进行 性能分析。该模块适用于Nginx开发人员,默认情况下未构建。</code></pre><p>–with-cpp_test_module</p>
<pre><code>启用构建 ngx_cpp_test_module模块。</code></pre><p>–add-module=path</p>
<pre><code>启用外部模块。</code></pre><p>–add-dynamic-module=path</p>
<pre><code>启用外部动态模块。</code></pre><p>–with-compat</p>
<pre><code>启用动态模块兼容性。</code></pre><p>–with-cc=path</p>
<pre><code>设置C编译器的名称。</code></pre><p>–with-cpp=path</p>
<pre><code>设置C预处理器的名称。</code></pre><p>–with-cc-opt=parameters</p>
<pre><code>设置将添加到CFLAGS变量的其他参数。在FreeBSD下使用系统PCRE库时, --with-cc-opt="-I /usr/local/include" 应指定。如果select()需要增加支持的文件数量,也可以在此处指定,例如: --with-cc-opt="-D FD_SETSIZE=2048"。</code></pre><p>–with-ld-opt=parameters</p>
<pre><code>设置将在链接期间使用的其他参数。在FreeBSD下使用系统PCRE库时, --with-ld-opt="-L /usr/local/lib" 应指定。</code></pre><p>–with-cpu-opt=cpu</p>
<pre><code>每个指定的CPU能够使建筑: pentium,pentiumpro, pentium3,pentium4, athlon,opteron, sparc32,sparc64, ppc64。</code></pre><p>–without-pcre</p>
<pre><code>禁用PCRE库的使用。</code></pre><p>–with-pcre</p>
<pre><code>强制使用PCRE库。</code></pre><p>–with-pcre=path</p>
<pre><code>设置PCRE库源的路径。需要从PCRE站点下载并分发库分发(版本4.4 — 8.43) 。其余的由nginx的./configure和完成 make。该库对于location指令中的正则表达式支持和 ngx_http_rewrite_module 模块是必需的 。</code></pre><p>–with-pcre-opt=parameters</p>
<pre><code>为PCRE设置其他构建选项。</code></pre><p>–with-pcre-jit</p>
<pre><code>使用“及时编译”支持(..2,pcre_jit指令)构建PCRE库 。</code></pre><p>–with-zlib=path</p>
<pre><code>设置zlib库源的路径。需要从zlib站点下载库发行版(版本..3-.2.) 并解压缩。其余的由nginx的./configure和完成 make。ngx_http_gzip_module模块需要该库 。</code></pre><p>–with-zlib-opt=parameters</p>
<pre><code>为zlib设置其他构建选项。</code></pre><p>–with-zlib-asm=cpu</p>
<pre><code>使得能够使用指定的CPU中的一个优化的zlib汇编源程序: pentium,pentiumpro。</code></pre><p>–with-libatomic</p>
<pre><code>强制使用libatomic_ops库。</code></pre><p>–with-libatomic=path</p>
<pre><code>设置libatomic_ops库源的路径。</code></pre><p>–with-openssl=path</p>
<pre><code>设置OpenSSL库源的路径。</code></pre><p>–with-openssl-opt=parameters</p>
<pre><code>为OpenSSL设置其他构建选项。</code></pre><p>–with-debug</p>
<pre><code>启用调试日志</code></pre></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://www.scery.com">HaoDong Wu</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://www.scery.com/nginx%E5%AE%89%E8%A3%85%E5%92%8C%E7%BC%96%E8%AF%91.htm">https://www.scery.com/nginx%E5%AE%89%E8%A3%85%E5%92%8C%E7%BC%96%E8%AF%91.htm</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://www.scery.com" target="_blank">Anthony's Blog</a>!</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="tags/Linux/">Linux</a><a class="post-meta__tags" href="tags/Service/">Service</a><a class="post-meta__tags" href="tags/Nginx/">Nginx</a></div><div class="post_share"><div class="social-share" data-image="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="centos7_%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91.htm"><img class="prev-cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Centos7_firewalld_端口转发</div></div></a></div><div class="next-post pull-right"><a href="nginx%E9%85%8D%E7%BD%AEphp.htm"><img class="next-cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Nginx配置PHP</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="Centos7%E5%AE%89%E8%A3%85mysql8.0.htm" title="Centos7安装mysql8.0和日常命令"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-02-20</div><div class="title">Centos7安装mysql8.0和日常命令</div></div></a></div><div><a href="Mysql%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85.htm" title="Centos7编译安装mysql8.0和日常命令"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-02-21</div><div class="title">Centos7编译安装mysql8.0和日常命令</div></div></a></div><div><a href="Nodejs%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE.htm" title="Nodejs环境配置"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-03-01</div><div class="title">Nodejs环境配置</div></div></a></div><div><a href="sftp.htm" title="Centos7_Sftp"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-20</div><div class="title">Centos7_Sftp</div></div></a></div><div><a href="Centos7_firewalld.htm" title="Centos7_firewalld"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-02-20</div><div class="title">Centos7_firewalld</div></div></a></div><div><a href="MongoDB%E5%BF%98%E8%AE%B0%E5%AF%86%E7%A0%81.htm" title="MongoDB重置密码"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-03-26</div><div class="title">MongoDB重置密码</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="../img/avatar.png" onerror="this.onerror=null;this.src='../img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">HaoDong Wu</div><div class="author-info__description">Email: [email protected]</div></div><div class="card-info-data site-data is-center"><a href="../archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="../tags/"><div class="headline">标签</div><div class="length-num">58</div></a><a href="/"><div class="headline">分类</div><div class="length-num">61</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/Anthonyfhd"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Anthonyfhd" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="../wuhaodong:[email protected]" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://weibo.com/u/5730157238" target="_blank" title="z"><i class="fab fa-weibo"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">I am a slow walker,but I never walk backwards.</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Nginx%E5%AE%89%E8%A3%85%E5%92%8C%E7%BC%96%E8%AF%91"><span class="toc-number">1.</span> <span class="toc-text">Nginx安装和编译</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#yum%E6%BA%90%E5%AE%89%E8%A3%85"><span class="toc-number">1.1.</span> <span class="toc-text">yum源安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85"><span class="toc-number">1.2.</span> <span class="toc-text">编译安装</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../XT20%E4%BD%BF%E7%94%A8%E6%96%B0%E6%9C%BA%E5%9E%8B%E7%9A%84%E9%A2%84%E8%AE%BE.htm" title="无题">无题</a><time datetime="2025-01-04T04:30:41.696Z" title="发表于 2025-01-04 12:30:41">2025-01-04</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E7%BB%84%E4%BC%9A/20241223%E7%BB%84%E4%BC%9A.htm" title="20241223组会">20241223组会</a><time datetime="2024-12-23T06:56:00.000Z" title="发表于 2024-12-23 14:56:00">2024-12-23</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E7%B2%BE%E5%87%86%E5%9B%BD%E9%99%85%E4%BC%A0%E6%92%AD%E7%B3%BB%E7%BB%9F/%E7%B2%BE%E4%BC%A0%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E6%9D%83%E9%99%90%E9%85%8D%E7%BD%AE.htm" title="精传系统页面权限配置">精传系统页面权限配置</a><time datetime="2024-12-16T00:48:25.000Z" title="发表于 2024-12-16 08:48:25">2024-12-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%E5%AE%9E%E9%AA%8C%E5%AE%A4/%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%201.htm" title="岳麓山数智传播 1">岳麓山数智传播 1</a><time datetime="2024-12-15T08:54:00.000Z" title="发表于 2024-12-15 16:54:00">2024-12-15</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%E5%AE%9E%E9%AA%8C%E5%AE%A4/%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD.htm" title="岳麓山数智传播">岳麓山数智传播</a><time datetime="2024-12-12T07:10:00.000Z" title="发表于 2024-12-12 15:10:00">2024-12-12</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">©2020 - 2025 By HaoDong Wu</div><div class="framework-info"></div><div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">粤ICP备2024239461号 </a>
<img src="/images/beian.png" style="display: inline-block;"><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=none" rel="noopener" target="_blank">粤公网安备号 </a>
</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span> 数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="js/utils.js"></script><script src="js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="js/search/local-search.js"></script><script>var preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")
}
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (!window.MathJax) {
window.MathJax = {
tex: {
inlineMath: [ ['$','$'], ["\\(","\\)"]],
tags: 'ams'
},
chtml: {
scale: 1.2
},
options: {
renderActions: {
findScript: [10, doc => {
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
const display = !!node.type.match(/; *mode=display/)
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
const text = document.createTextNode('')
node.parentNode.replaceChild(text, node)
math.start = {node: text, delim: '', n: 0}
math.end = {node: text, delim: '', n: 0}
doc.math.push(math)
}
}, ''],
insertScript: [200, () => {
document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
const target = node.parentNode
if (target.nodeName.toLowerCase() === 'li') {
target.parentNode.classList.add('has-jax')
} else {
target.classList.add('has-jax')
}
});
}, '', false]
}
}
}
const script = document.createElement('script')
script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
script.id = 'MathJax-script'
script.async = true
document.head.appendChild(script)
} else {
MathJax.startup.document.state(0)
MathJax.texReset()
MathJax.typeset()
}</script><script>function addGitalkSource () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
document.getElementsByTagName('head')[0].appendChild(ele)
}
function loadGitalk () {
function initGitalk () {
var gitalk = new Gitalk(Object.assign({
clientID: '85556d73db8de5db1c7f',
clientSecret: 'c62529657d2e66f49a40272e9aa404225a1952c3',
repo: 'Blog_GitTalk',
owner: 'Anthonyfhd',
admin: ['Anthonyfhd'],
id: 'd41d8cd98f00b204e9800998ecf8427e',
updateCountCallback: commentCount
},null))
gitalk.render('gitalk-container')
}
if (typeof Gitalk === 'function') initGitalk()
else {
addGitalkSource()
getScript('https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.js').then(initGitalk)
}
}
function commentCount(n){
let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
if (isCommentCount) {
isCommentCount.innerHTML= n
}
}
if ('Gitalk' === 'Gitalk' || !true) {
if (true) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
else loadGitalk()
} else {
function loadOtherComment () {
loadGitalk()
}
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>