nginx安装(centOS7)


先将 nginx 的源加入 yum 

[root@diya-dos ~]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm Retrieving http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm warning: /var/tmp/rpm-tmp.XJmHf8: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY Preparing... ################################# [100%] Updating / installing... 1:nginx-release-centos-7-0.el7.ngx ################################# [100%] [root@diya-dos ~]#
查看nginx信息

[root@diya-dos ~]# yum info nginx Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 3.2 kB 00:00:00 extras | 3.4 kB 00:00:00 nginx | 2.9 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): epel/x86_64/updateinfo | 931 kB 00:00:00 (2/3): epel/x86_64/primary | 3.6 MB 00:00:00 (3/3): nginx/x86_64/primary_db | 35 kB 00:00:00 Loading mirror speeds from cached hostfile epel 12636/12636 Available Packages Name : nginx Arch : x86_64 Epoch : 1 Version : 1.14.0 Release : 1.el7_4.ngx Size : 750 k Repo : nginx/x86_64 Summary : High performance web server URL : http://nginx.org/ License : 2-clause BSD-like license Description : nginx [engine x] is an HTTP and reverse proxy server, as well as : a mail proxy server. [root@diya-dos ~]#

yum安装nginx

[root@diya-dos ~]#  yum install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.14.0-1.el7_4.ngx will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                              Arch                                  Version                                             Repository                            Size
===========================================================================================================================================================================
Installing:
 nginx                                x86_64                                1:1.14.0-1.el7_4.ngx                                nginx                                750 k

Transaction Summary
===========================================================================================================================================================================
Install  1 Package

Total download size: 750 k
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
nginx-1.14.0-1.el7_4.ngx.x86_64.rpm                                                                                                                 | 750 kB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 1:nginx-1.14.0-1.el7_4.ngx.x86_64                                                                                                                       1/1 
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
  Verifying  : 1:nginx-1.14.0-1.el7_4.ngx.x86_64                                                                                                                       1/1 

Installed:
  nginx.x86_64 1:1.14.0-1.el7_4.ngx                                                                                                                                        

Complete!
[root@diya-dos ~]#

查看版本以及启动nginx

[root@diya-dos ~]# nginx -v
nginx version: nginx/1.14.0
[root@diya-dos ~]# service nginx start
Redirecting to /bin/systemctl start nginx.service
[root@diya-dos ~]# 

访问页面(浏览器访问localhost),没浏览器可以用curl命令

[root@diya-dos ~]# curl -i localhost
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Fri, 10 Aug 2018 08:39:54 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 17 Apr 2018 15:48:00 GMT
Connection: keep-alive
ETag: "5ad61730-264"
Accept-Ranges: bytes

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this 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 you for using nginx.</em></p>
</body>
</html>
[root@diya-dos ~]# 

可以看到返回了一个html页面,说明可以正常访问

猜你喜欢

转载自www.cnblogs.com/pipipi/p/9455954.html