1、下载安装包
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
2、配置nginx所需环境
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
3、解压安装包
tar -zxvf nginx-1.10.1.tar.gz
4、配置
cd nginx-1.10.1
./configure
5、编译
make
make install
6、启动
cd usr/local/nginx/sbin #nginx所在路径
./nginx
浏览器中输入主机ip可查看是否启动成功
7、设置开机自启
vim /etc/rc.local
#底部加/usr/local/nginx/sbin/nginx nginx所在路径
8、加入环境变量
vim /etc/profile
PATH=/usr/local/nginx/sbin:
9、执行
source /etc/profile