需要使用编译方式安装,清访问:Centos源码编译安装配置Nginx
1、查询是否已经安装了nginx
rpm -qa|grep nginx #如果有安装了 ,执行rpm -e nginx卸载
2、下载nginx rpm包并安装
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm #也可去http://nginx.org/packages/centos/7/x86_64/RPMS/找合适的版本 rpm -ivh nginx-1.18.0-1.el7.ngx.x86_64.rpm #默认安装位置/etc/nginx/,配置文件/etc/nginx/nginx.conf #如果提示需要依赖可以使用yum安装解决 yum install nginx-1.18.0-1.el7.ngx.x86_64.rpm
3、启动、重启、停止nginx
systemctl start nginx systemctl status nginx systemctl stop nginx
4、设置开机自启动
systemctl enable nginx systemctl list-unit-files|grep nginx
5、关闭防火墙
#如果其他主机无法访问,需要关闭防火墙 systemctl stop firewalld systemctl disable firewalld
转载请注明:零五宝典 » Linux CentOS7使用rpm方式安装nginx