Centos7 | Nginx installation and configuration (yum install)

First, the source added yum

No case Centos7 default source Nginx recently discovered Nginx official website provides the source address of Centos. Add commands can be performed as follows Source:

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

Second, install Nginx

To see if the source has been added successfully yum search nginx. If successful, execute the following command to install Nginx.

yum search nginx
yum install -y nginx

Third, start Nginx and set to start automatically

(开启服务后需要稍等片刻才能加入开机自启动)

systemctl start nginx.service
systemctl enable nginx.service

## 4. Open the appropriate ports in your firewall or turn off the firewall (Ali cloud also need to separate), click View firewall Introduction

#安装iptables防火墙(如果有需要)
yum install iptables-services 
#配置iptables
vim /etc/sysconfig/iptables

#添加端口  
firewall-cmd --zone=public --add-port=80/tcp --permanent (–permanent永久生效,没有此参数重启后失效)
#重新载入
firewall-cmd --reload
#查看所有打开的端口
firewall-cmd --zone=public --list-ports

V. View to see the effect

Enter your server address in your browser: ip + port number or domain name

The following is the default path of Nginx:

(1) Nginx配置路径:/etc/nginx/

(2) PID目录:/var/run/nginx.pid

(3) 错误日志:/var/log/nginx/error.log

(4) 访问日志:/var/log/nginx/access.log

(5) 默认站点目录:/usr/share/nginx/html

In fact, just know Nginx configuration path, the other path can be queried in the /etc/nginx/nginx.conf and /etc/nginx/conf.d/default.conf

Published 35 original articles · won praise 4 · Views 1064

Guess you like

Origin blog.csdn.net/qq_41980405/article/details/101770187