一、官網下載源碼
http://nginx.org/en/download.html
二、上傳到指定的安裝目錄
tar vxf nginx-1.16.1.tar.gz
cd cd nginx-1.16.1 && ./config --prefix=/etc/nginx
./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 -y install openssl openssl-devel
checking for zlib library ... not found
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
安裝需要的插件
yum install zlib-devel -y
./configure --prefix=/usr/local/nginx
make
三、啓動nginx
./sbin/nginx
四、查看nginx 啓動配置詳情
./sbin/nginx -t
五、隱藏nginx版本號
vim conf/nginx.conf
http server 路徑下添加 server_tokens off;
vim conf/fastcgi.conf
修改 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param SERVER_SOFTWARE nginx;
重啓或者reload nginx
pkill nginx && ./sbin/nginx