Installation and Configuration Nginx (yum installed)

A, Nginx installation and configuration

1. Add yum source

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

2. 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

3. Start Nginx

(1) Start Nginx and set to start automatically

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

systemctl start nginx.service
systemctl enable nginx.service

(2) to open or close the respective ports firewall firewall

Open ports in the 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

4. Browse 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 /etc/nginx/nginx.conf and /etc/nginx/conf.d/default.conf in.

Guess you like

Origin www.cnblogs.com/fanhengbin/p/11839498.html