安装方式:编译安装

  1. 编译环境

    yum install gcc gcc-c++ make unzip pcre pcre-devel zlib zlib-devel libxml2 libxml2-devel  readline readline-devel ncurses ncurses-devel perl-devel perl-ExtUtils-Embed openssl-devel -y
    
  2. 获取源码

    wget -c http://nginx.org/download/nginx-1.16.1.tar.gz
    tar -zxvf nginx-1.16.1.tar.gz
    
  3. 编译检查与安装

    cd nginx-1.16.1
    ./configure
    make -j4 && make install   ##默认安装到/usr/local下
    
  4. 用户权限调整

    useradd nginx
    chown nginx:nginx /usr/local/nginx
    
  5. 验证安装

    cd /usr/local/nginx/sbin/
    ./nginx -v  ##查看版本
    ./nginx ##运行
    
    [[email protected] ~]# ps -aux | grep nginx
    root       40335  0.0  0.0   5248  1536 ?        Ss   11:25   0:00 nginx: master process ./nginx
    nobody     40337  0.0  0.0   6464  3712 ?        S    11:25   0:00 nginx: worker process
    root       40466  0.0  0.0 214016  1600 pts/0    S+   11:30   0:00 grep --color=auto nginx
    [[email protected] ~]# netstat -tunlp | grep 80
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      40335/nginx: master
    [[email protected] ~]# curl 127.0.0.1
    <html>
    <head><title>403 Forbidden</title></head>
    <body>
    <center><h1>403 Forbidden</h1></center>
    <hr><center>nginx/1.16.1</center>
    </body>
    </html>