Linux安装Nginx
# Linux安装nginx
# 预先安装一些包
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
1
# 下载安装包
我使用wget下载,先安装wget:yum install wget -y
,然后开始下载nginx并且解压,然后删除安装包节省空间。
cd /usr/local/ && \
wget http://nginx.org/download/nginx-1.24.0.tar.gz && \
tar -xvf nginx-1.24.0.tar.gz && \
rm -f nginx-1.24.0.tar.gz
1
2
3
4
2
3
4
# 编译一些常用模块
模块说明推荐阅读这位大佬的文章 (opens new window)
cd nginx-1.24.0 && \
mkdir /var/temp/nginx -p && \
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_ssl_module \
--with-threads \
--with-file-aio \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_slice_module \
--with-mail \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream \
--with-stream=dynamic \
--with-stream_ssl_module
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
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
# 安装
make && make install
1
# 配置环境变量
echo 'PATH=$PATH:/usr/local/nginx/sbin' >> /etc/profile && \
echo 'export PATH' >> /etc/profile && \
source /etc/profile && \
nginx -V
1
2
3
4
2
3
4
# 常用操作命令
# 启动nginx
nginx -c /usr/local/nginx/conf/nginx.conf
# 查看nginx进程
ps -ef | grep nginx
# 处理完请求后停止
nginx -s quit
# 强制停止
nginx -s stop
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
nginx位于:/usr/local/nginx
编辑 (opens new window)
上次更新: 2023/05/28, 08:23:00