1.安装依赖包
yum install -y pcre* openssl*
2.添加用户不允许登陆
useradd -s /sbin/nologin -M nginx
3.官网下载源码包
http://nginx.org/download/nginx-1.14.2.tar.gz
解压
tar xf nginx-1.14.2.tar.gz
4,修改版本号
a. vim src/core/nginx.h 13行
#define NGINX_VERSION "9.9.9"
#define NGINX_VER "xxx/" NGINX_VERSION
b. vim src/http/ngx_http_special_response.c 29行
"<hr><center>xxx_ws</center>" CRLF
5. 编译安装
./configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --with-http_image_filter_module
6. 复制nginx到/usr/bin下可快速启动
cp /usr/local/nginx/sbin/nginx /usr/bin/nginx
网站在/usr/local/nginx/html/下,如有需要可自行修改/usr/local/conf/nginx.conf文件44行 root目录
location / {
44 root html;
45 index index.html index.htm;
46 }