1,安装nginx依赖
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
如图:
安装成功:
2,下载nginx-1.17.1.tar.gz,上传至/usr/local/src目录下
下载地址:https://nginx.org/download/
#进入目录
cd /usr/local/src
#解压文件
tar -zxvf nginx-1.17.1.tar.gz
##进入nginx目录
cd nginx-1.17.1
## 配置
./configure --prefix=/usr/local/nginx
# make
make
make install
#查看是否安装成功
cd /usr/local/nginx/sbin
./nginx -t
如图:成功
3,启动nginx
命令:./nginx
查看:ps -ef | grep nginx
启动成功如图:
4,通过ip访问如图表示成功了:
5,设置开机自启动
vim /etc/rc.d/rc.local
添加一行/usr/local/nginx/sbin/nginx