The Yum in CentOS 7 cannot directly use the Yum install nginx command to install Nginx, because Nginx is not a service that is brought in Yum Library. Figure 1 is the official provision of the approximate installation steps, Figure 2 is the website provided by a number of versions of the Nginx installation package, the following is my own system environment summary of the installation method for your reference:
Figure 1
Figure 2
1, according to the requirements in Figure 1 VI nginx.repo This file, the figure in the [Nginx] field in the contents of the copy in, save exit.
[Root@lnboxue ~]# Vi/etc/yum.repos.d/nginx.repo
[Nginx]
Name=nginx Repo
baseurl=http://nginx.org/packages/centos/7/x86_64/
Gpgcheck=0
Enabled=1
Note here: To replace the $releasever with 7, replace the $basearch with the x86_64. You can get the $releasever and $basearch of your own system by following this instruction.
[Root@lnboxue ~]# Rpm-qa | grep centos-release
Centos-release-7-3.1611.el7.centos.x86_64
2, yum installation nginx, see Figure 3 and Figure 4.
[Root@lnboxue ~]# Yum Install Nginx
Figure 3
Figure 4 3, you can start the Nginx service using two methods
[Root@lnboxue ~]# service Nginx start
Or
[Root@lnboxue ~]# systemctl start Nginx
4, to see if the Nginx service has been started
[Root@lnboxue ~]# Netstat-ntl
Figure 5
5, view nginx version [Root@lnboxue ~]# nginx-v
Nginx version:nginx/1.12.0
6. Local Testing Nginx Service
[Root@lnboxue ~]# curl-i localhost
http/1.1 OK
server:nginx/1.12.0
Date:tue, June 2017 05:27:07 GMT
Content-type:text/html
content-length:612
last-modified:wed, APR 2017 15:23:46 GMT
............
............
<p>if you are here page, the Nginx Web server is successfully installed and
Working. Further configuration is required.</p>
<p>for online documentation and support please refer to
<a href= "http://nginx.org/" >nginx.org</a>.<br/>
Commercial support is available at
<a href= "http://nginx.com/" >nginx.com</a>.</p>
<p><em>thank for using nginx.</em></p>
</body>
See the above information to indicate that your Nginx service has been successfully installed.