# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# yum install nginx #yum会自动安装nginx的相关依赖包
# chkconfig nginx on # CentOS6# systemctl enable nginx.service # CentOS7
默认安装目录/usr/local/nginx默认网站根目录/usr/local/nginx/html默认配置文件目录/usr/local/nginx/conf/nginx.conf
# yum -y install gcc gcc-c++ zlib-devel pcre-devel openssl-devel
# tar -zxvf nginx-1.15.2.tar.gz #解压# cd nginx-1.15.2# ./configure #检查环境,设置安装参数,可以设置安装路径、第三方模块,--add-module表示要安装的模块,--prefix表示安装路径,这里不设置用默认的。# make# make install
# vim /usr/local/nginx/conf/nginx.conf
# chkconfig nginx on # CentOS6# systemctl enable nginx.service # CentOS7
默认安装目录/usr/local/nginx默认网站根目录/usr/local/nginx/html默认配置文件目录/usr/local/nginx/conf/nginx.conf