使用yum源直接安装nginx
1、配置nginx源
centos6:
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
|---|-----------------------------------------------------------------------------------------------------| | 1 | rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm |
centos7:
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
|---|-----------------------------------------------------------------------------------------------------| | 1 | rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm |
2、安装nginx(默认会安装最新的稳定版)
yum -y install nginx
|---|----------------------| | 1 | yum -y install nginx |
3、默认配置文件
/etc/nginx/nginx.conf
4、设置开机自启及启动nginx
centos6:
chkconfig nginx on service nginx start
|-----|----------------------------------------| | 1 2 | chkconfig nginx on service nginx start |
centos7:
systemctl enable nginx systemctl start nginx
|-----|----------------------------------------------| | 1 2 | systemctl enable nginx systemctl start nginx |