Install Nginx on CentOS 7

时间:2023-03-09 08:31:05
Install Nginx on CentOS 7

To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1

Replace "OS" with "rhel" or "centos", depending on the distribution used, and "OSRELEASE" with "6" or "7", for 6.x or 7.x versions, respectively.

install Nginx using the following yum command:

sudo yum install -y nginx

或者

rpm -Uvh https://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

默认安装在这个路径

/etc/nginx

如果想禁止使用IP访问80、443 参考https://www.jianshu.com/p/c632e98468cd