NGINX--安装

1、环境准备

版本:nginx-1.22.1
操作系统:CentOS Linux release 7.9.2009 (Core)
环境检查:

rpm -qa | grep pcre
rpm -qa | grep pcre-devel
rpm -qa | grep openssl
rpm -qa | grep openssl-devel
rpm -qa | grep zlib
rpm -qa | grep zlib-devel
rpm -qa | grep automake
rpm -qa | grep autoconf
rpm -qa | grep libtool
rpm -qa | grep make
rpm -qa | grep gcc
rpm -qa | grep gcc-c++
rpm -qa | grep patch

如果上面没有的包请安装,否则会报如下错误

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

yum安装命令如下

yum install automake  autoconf make libtool -y
yum install pcre pcre-devel -y
yum install zlib zlib-devel -y
yum install gcc  gcc-c++ -y
yum install patch -y

2、下载URL

在应用用户下(非root用户)进行下载,安装

wget -c https://nginx.org/download/nginx-1.22.1.tar.gz

3、解压、目录详解

解压

cd
tar -zxvf nginx-1.22.1.tar.gz

解压之后的目录如下:

total 804
drwxr-xr-x. 6 yiifung yiifung   4096 May 21 06:26 auto
-rw-r--r--. 1 yiifung yiifung 317399 Oct 19  2022 CHANGES
-rw-r--r--. 1 yiifung yiifung 485035 Oct 19  2022 CHANGES.ru
drwxr-xr-x. 2 yiifung yiifung    168 May 21 06:26 conf
-rwxr-xr-x. 1 yiifung yiifung   2590 Oct 19  2022 configure
drwxr-xr-x. 4 yiifung yiifung     72 May 21 06:26 contrib
drwxr-xr-x. 2 yiifung yiifung     40 May 21 06:26 html
-rw-r--r--. 1 yiifung yiifung   1397 Oct 19  2022 LICENSE
drwxr-xr-x. 2 yiifung yiifung     21 May 21 06:26 man
-rw-r--r--. 1 yiifung yiifung     49 Oct 19  2022 README
drwxr-xr-x. 9 yiifung yiifung     91 May 21 06:26 src

4、构建(BUILD)、MAKE

cd $HOME/nginx-1.22.1
./configure  --prefix=$HOME/nginx \
             --sbin-path=$HOME/nginx/sbin/nginx \
             --user=yiifung \
             --group=yiifung \
             --with-stream \
             --with-http_ssl_module \
             --with-http_stub_status_module \
             --with-http_realip_module \

构建(BUILD)之后的结果如下

Configuration summary
  + using PCRE2 library: /home/yiifung/pcre2-pcre2-10.42
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/home/yiifung/nginx"
  nginx binary file: "/home/yiifung/nginx/sbin"
  nginx modules path: "/home/yiifung/nginx/modules"
  nginx configuration prefix: "/home/yiifung/nginx/conf"
  nginx configuration file: "/home/yiifung/nginx/conf/nginx.conf"
  nginx pid file: "/home/yiifung/nginx/logs/nginx.pid"
  nginx error log file: "/home/yiifung/nginx/logs/error.log"
  nginx http access log file: "/home/yiifung/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

MAKE

make
make install 

5、启动、检查

cd $HOME/nginx/sbin
./nginx
ps -ef | grep nginx
yiifung@localhost sbin]$ ps -ef | grep nginx
yiifung   25508      1  0 07:53 ?        00:00:00 nginx: master process ./nginx
yiifung   25510  25508  0 07:53 ?        00:00:00 nginx: worker process

6、注意点

如果pcre、pcre-devel、zlib、zlib-devel等这些命令无法通过yum安装,也可以通过源码进行安装使用

cd $HOME/nginx-1.22.1
./configure  --prefix=$HOME/nginx \
             --sbin-path=$HOME/nginx/sbin/nginx \
             --user=yiifung \
             --group=yiifung \
             --with-stream \
             --with-http_ssl_module \
             --with-http_stub_status_module \
             --with-http_realip_module \
             --with-pcre=$HOME/pcre2-10.39
             --with-zlib=$HOME/zlib-1.2.11
             --with-openssl=$HOME/opessl-1.2.1

pcre2、zlib下载地址如下

wget -c https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
wget -c http://zlib.net/fossils/zlib-1.2.11.tar.gz
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值