If you install Nginx in CentOS for the first time, you need to add Nginx software package, use the following name, add installation

Add the nginx yum repository

sudo yum install yum-utils

2, set the yum repository, create a configuration file/etc/yum repos. D/nginx. Repo, the content is as follows

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
Copy the code

Install nginx

sudo yum install nginx 

4. Configure nginx after startup

systemctl enable nginx 

Start the nginx service

Start systemctl start nginx

Stop systemctl stop nginx

Restart systemctl reolad nginx

View the process information ps – ef | grep nginx

Find / -name nginx

If the following page is displayed, the Nginx installation is successful

Note: Make sure port 80 is connected first

1 Check whether the port is open firewall-cmd –list-all

2 Run sudo firewall-cmd –add-port=80/ TCP –permanent

3 Restart the firewall firewall-cmd –reload

Part from: www.cnblogs.com/alan-lin/p/…