1、官网下载源码包
http://nginx.org/en/download.html
2、依赖包下载
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
3、解压
tar xf nginx-1.14.2.tar.gz
4、编译安装
cd nginx-1.14.2
自定义参数,我这里简单写了一些
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/conf/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log
make -j4
make install
5、启动测试
/usr/local/nginx/sbin/nginx -V //查看nginx信息
ps -ef | grep nginx
ss -ltnp | grep 80
/usr/local/nginx/sbin/nginx //启动
浏览器访问:http://IP
升级操作
1、官网下载最新版本的包
2、备份
cp -rf /usr/local/nginx /usr/local/nginx.old
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
2、解压
tar xf nginx-1.18.0.tar.gz
3、杀掉nginx进程
pkill nginx
4、编译(不能执行安装)
cd ng