Skip to content

Commit ab344c0

Browse files
author
luzhicheng
committed
nginx安装
nginx安装
1 parent 2bb5225 commit ab344c0

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed

linux/centos7安装nginx.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# centos7安装nginx
2+
[参考Nginx安装](https://www.nginx.cn/install)
3+
## 1.centos平台编译环境使用如下指令
4+
```python
5+
# 安装make
6+
yum -y install gcc automake autoconf libtool make
7+
# 安装g++
8+
yum install gcc gcc-c++
9+
```
10+
11+
## 2.开始安装
12+
* 选定源码目录
13+
* 安装PCRE库
14+
* 安装zlib库
15+
* 安装ssl
16+
* 安装nginx
17+
18+
#### 2.1.选定源码目录
19+
```python
20+
# 指定源码的目录
21+
cd /usr/local/src
22+
```
23+
#### 2.2.安装PCRE库
24+
```python
25+
cd /usr/local/src
26+
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
27+
tar -zxvf pcre-8.44.tar.gz
28+
cd pcre-8.44
29+
./configure
30+
make
31+
make install
32+
```
33+
#### 2.3.安装zlib
34+
```python
35+
wget http://zlib.net/zlib-1.2.11.tar.gz
36+
tar -zxvf zlib-1.2.11.tar.gz
37+
cd zlib-1.2.11
38+
./configure
39+
make
40+
make install
41+
```
42+
#### 2.4.安装ssl
43+
```python
44+
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
45+
tar -zxvf openssl-1.1.1g.tar.gz
46+
cd openssl-1.1.1g
47+
./config
48+
make
49+
make install
50+
```
51+
#### 2.5.安装nginx
52+
```python
53+
wget http://nginx.org/download/nginx-1.18.0.tar.gz
54+
tar -zxvf nginx-1.18.0.tar.gz
55+
cd nginx-1.18.0
56+
57+
# 默认安装
58+
./configure & make & make install
59+
60+
# 自定义编译安装
61+
# ./configure --sbin-path=/usr/local/nginx/nginx \
62+
# --conf-path=/usr/local/nginx/nginx.conf \
63+
# --pid-path=/usr/local/nginx/nginx.pid \
64+
# --with-http_gzip_static_module \
65+
# --with-http_stub_status_module \
66+
# --with-file-aio \
67+
# --with-http_realip_module \
68+
# --with-http_ssl_module \
69+
# --with-pcre=/usr/local/src/pcre-8.44 \
70+
# --with-zlib=/usr/local/src/zlib-1.2.11 \
71+
# --with-openssl=/usr/local/src/openssl-1.1.1g
72+
73+
# make
74+
# make install
75+
```
76+
77+
**Nginx编译选项**
78+
79+
* --prefix=path: 自定义nginx的安装目录,默认/usr/local/nginx
80+
* --sbin-path=path:定义nginx可执行文件的路径,默认prefix/sbin/nginx
81+
* --conf-path=path:设置nginx.conf配置文件路径,默认prefix/conf/nginx.conf,可以通过nginx -c config_path,启动的时候指定配置文件
82+
* --pid-path=path: 设置nginx.pid文件,将存储的主进程的进程号,默认prefix/logs/nginx.pid
83+
* --error-log-path=path: 设置主错误,警告,和诊断文件的名称,默认prefix/logs/error.log
84+
* --http-log-path=path: 设置主请求的HTTP服务器的日志文件的名称,默认prefix/logs/access.log
85+
* --user=name 设置nginx工作进程的用户,默认nobody
86+
* --group=name 设置nginx工作进程的用户组
87+
* --with-pcre=/usr/local/src/pcre-8.44: 指定pcre源码路径
88+
* --with-zlib=/usr/local/src/zlib-1.2.11: 指定zlib源码路径
89+
* --with-openssl=/usr/local/src/openssl-1.1.1g: 指定ssl源码路径
90+
91+
## 3.运行nginx
92+
```python
93+
[root@iZ8vb6ughzbdqkfd58dowoZ nginx]# ls
94+
client_body_temp fastcgi.conf.default fastcgi_temp koi-win mime.types.default nginx.conf.default sbin scgi_temp uwsgi_temp
95+
conf fastcgi_params html logs nginx nginx.pid scgi_params uwsgi_params win-utf
96+
fastcgi.conf fastcgi_params.default koi-utf mime.types nginx.conf proxy_temp scgi_params.default uwsgi_params.default
97+
[root@iZ8vb6ughzbdqkfd58dowoZ nginx]# ./nginx
98+
```
99+
100+
* 启动: /usr/local/nginx/sbin/nginx
101+
* 停止/重启: /usr/local/nginx/sbin/nginx -s stop(quit、reload)
102+
* 帮助: /usr/local/nginx/sbin/nginx -h
103+
* 配置文件: vim /usr/local/nginx/conf/nginx.conf

linux/main.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
8. [正则表达式](正则表达式.md)
1212
9. [sed命令与awk命令](sed命令与awk命令.md)
1313

14+
## Nginx
15+
1. [centos7安装nginx](centos7安装nginx.md)
16+
1417

1518
## 常用命令
1619
1. [常用系统工作命令(echo, date, reboot, poweroff, wget, ps, top, pidof, kill, killall, whereis, locate, tar, sync)](Linux常用系统工作命令.md)
1020 KB
Binary file not shown.
9.35 MB
Binary file not shown.
1.99 MB
Binary file not shown.
593 KB
Binary file not shown.

0 commit comments

Comments
 (0)