1.配置相关环境:
yum install gcc glibc gcc-c++ zlib pcre-devel openssl-devel
2.创建nginx用户
useradd -s /sbin/nologin -M www
3.进入用户级源码目录并下载nginx源码
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
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
10.进行配置文件测试
/usr/local/nginx/sbin/nginx -t
11.启动nginx
/usr/local/nginx/sbin/nginx