1.配置相关环境:
yum install gcc glibc gcc-c++ zlib pcre-devel openssl-devel
知识兔rewrite模块需要pcre库
ssl功能需要openssl库
gzip模块需要zlib库
2.创建nginx用户
useradd -s /sbin/nologin -M www
知识兔-M 不创建家目录
3.进入用户级源码目录并下载nginx源码
www.nginx.org
知识兔
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.0.tar.gz
4.解压源码包并进入nginx目录、
tar xzvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/
知识兔5.执行./configure脚本检查环境,生成安装规则文件makefile
./configure --prefix=/usr/local/nginx-1.12.0 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
知识兔--with-http_stub_status_module 状态模块,用于监控nginx
6.根据makefile文件编译安装
make && make install
知识兔7.创建软连接
ln -s /usr/local/nginx-1.12.0/ /usr/local/nginx
知识兔8.查看80端口是否被占用
netstat -ntlp
知识兔9.编辑配置文件/usr/local/nginx/conf/nginx.conf
vim /usr/local/nginx/conf/nginx.conf
知识兔location 用于匹配统一资源标识符(URI)
10.进行配置文件测试
/usr/local/nginx/sbin/nginx -t
知识兔11.启动nginx
/usr/local/nginx/sbin/nginx
知识兔/usr/local/nginx/sbin/nginx -s reload 重启nginx