1,查看nginx所需的依赖包
rpm -qa pcre zlib openssl pcre-devel zlib-devel openssl-devel
yum install -y pcre-devel zlib-devel openssl-devel
2,利用编译的方式安装pcre依赖库,可以使用rewrite重写功能
wget https://sourceforge.net/projects/pcre/files/pcre2/10.33/pcre2-10.33.tar.gz
tar xf pcre2-10.33.tar.gz
cd pcre2-10.33
./configure
make && make install
3,安装zlib库,为gzip压缩
wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz
tar xf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
4,添加用户
useradd nginx -s /sbin/nologin -M
5,下载源码包,采用编译方式安装
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar xf nginx-1.16.0.tar.gz
cd nginx-1.16.0
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.16.0 --with-http_ssl_module --with-http_stub_status_module
make && make install
6,进入安装目录,并做软链接
ln -s /application/nginx-1.16.0/ /application/nginx
7,检查语法,然后启动服务并查看端口
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
netstat -tunlp|grep 80
8,查看网站是否安装成功
10.0.0.31:80