安装nginx
-
下载包
wget http://nginx.org/download/nginx-1.16.1.tar.gz
-
解压包
tar xf nginx-1.16.1.tar.gz cd nginx-1.16.1
-
预编译
./configure
- 预编译主要是用来检查系统环境是否满足安装软件包的条件, 并生成Makefile文件,该文件为编译、安装、升级nginx指明了相应参数。
./configure - –help 可以查看预编译参数
- –prefix 指定nginx编译安装的目录;
- –user=*** 指定nginx的属主 **
- –group=* 指定nginx的属主与属组
- –with-*** 指定编译某模块 **
- –without- 指定不编译某模块
- –add-module 编译第三方模块
-
若有报错,添加依赖
checking for PCRE library ... not found checking for PCRE library in /usr/local/ ... not found checking for PCRE library in /usr/include/pcre/ ... not found checking for PCRE library in /usr/pkg/ ... not found checking for PCRE library in /opt/local/ ... not found ./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 install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y
安装完依赖包后,重新编译并指定安装目录:
./configure --prefix=/usr/local/nginx
-
修改头文件,改变响应头信息中nginx的版本为,server : JFWS/1.1
vim /nginx-1.16.1/src/core/nginx.h 修改第13,14行 #define NGINX_VERSION "1.1" #define NGINX_VER "JFWS/" NGINX_VERSION
-
编译并安装
make && make install
-
查看版本并启动程序
/usr/local/nginx/sbin/nginx -v nginx version: JFWS/1.1 # 启动程序 /usr/local/nginx/sbin/nginx
-
查看进程
ps -ef|grep nginx root 11258 1 0 23:34 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin nobody 11259 11258 0 23:34 ? 00:00:00 nginx: worker process root 11261 7360 0 23:35 pts/1 00:00:00 grep --color=auto nginx netstat -ntlp|grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11258/nginx: master
-
查看网页浏览器