//一键安装四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
// 创建文件夹
cd /usr/local/xxx
//下载tar包,并解压
tar –zxvf nginx-1.12.2.tar.gz
//进入解压后的nginx目录,执行./configure命令。--with是添加一些模块,可自行选择
./configure --prefix=/usr/local/xxx/nginx --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-threads
//执行make、make install命令
make
make install
//启动nginx
cd usr/local/xxx/nginx/sbin
./nginx
//停止nginx
cd usr/local/xxx/nginx/sbin
./nginx –s stop
//重启nginx
cd usr/local/xxx/nginx/sbin
./nginx –s reload
//判断配置文件是否正确
cd usr/local/xxx/nginx/sbin
./nginx -t
我这里是修改了nginx默认启动端口,由80改为81,修改完配置文件重启nginx,在浏览器输入地址,看到下图即证明nginx安装成功!