step1:配置本地 yum库,保存
$vi
/etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
其中,"OS"为系统类型,如centos, rhel;"OSRELEASE"为系统发布版本,如“6”,“7”
[nginx]
name=nginx repo
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
step2:yum安装
$ sudo yum install -y nginx
step3:启动服务
## 启动服务
$ nginx
## 关闭nginx服务
$ nginx -s stop
step4:部署测试
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
## 配置文件路径
$ vi /etc/nginx/nginx.conf
或者
$ vi /etc/nginx/init.d/default.conf
最后访问web路径:
http://test-host/