1.安装依赖包
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2.下载并解压安装包
//创建一个文件夹
cd /
cd /usr/local/
mkdir nginx
cd nginx
//下载tar 包
wget http://nginx.org/download/nginx-1.20.0.tar.gz
//解压tar包
tar -xvf nginx-1.13.7.tar.gz
3.安装nginx
//进入nginx目录
cd /usr/local/nginx
//进入目录
cd /nginx-1.20.0
//执行命令
./configure
make
//执行make install命令
make install
注意:可能会出现make install 失败的情况 ,考虑提高nginx版本
4.启动nginx
cd /usr/local/nginx/sbin
./nginx -s reload
如果出现
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
执行
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
再次执行
./nginx -s reload
ps -ef | grep naingx
查询到进程,启动成功,需要什么配置,访问/usr/local/nginx/conf/nginx.conf添加;