NGINX在CENTOS6的安装

本文提供了一步一步的指导,教你如何在CentOS 6系统上配置YUM源并安装NGINX。包括配置repo文件、清理缓存、安装NGINX以及启动测试等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 配置yum源。

NGINX官网地址

操作系统为centos6,配置repo文件如下:

[root@localhost ~]# cat /etc/yum.repos.d/nginx.repo 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1

2 清理缓存并安装。

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: CentOS nginx
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
CentOS                                                   | 3.7 kB     00:00     
CentOS/group_gz                                          | 226 kB     00:00     
CentOS/filelists_db                                      | 6.4 MB     00:00     
CentOS/primary_db                                        | 4.7 MB     00:01     
CentOS/other_db                                          | 2.8 MB     00:00     
nginx                                                    | 2.9 kB     00:00     
nginx/filelists_db                                       |  43 kB     00:00     
nginx/primary_db                                         |  37 kB     00:00     
nginx/other_db                                           |  18 kB     00:00     
Metadata Cache Created
[root@localhost yum.repos.d]# yum list nginx
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Available Packages
nginx.x86_64                       1.14.0-1.el6.ngx                        nginx
[root@localhost yum.repos.d]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)      
[root@localhost yum.repos.d]# /etc/init.d/httpd status
httpd is stopped
[root@localhost yum.repos.d]# netstat -tunlp|grep 80
udp        0      0 0.0.0.0:680                 0.0.0.0:*                               1353/rpcbind        
udp        0      0 :::680                      :::*                                    1353/rpcbind        
[root@localhost yum.repos.d]# yum install nginx
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.14.0-1.el6.ngx will be installed
--> Finished Dependency Resolution

Dependencies Resolved

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

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 956 k
Installed size: 2.6 M
Is this ok [y/N]: y
Downloading Packages:
nginx-1.14.0-1.el6.ngx.x86_64.rpm                        | 956 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : nginx-1.14.0-1.el6.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  : nginx-1.14.0-1.el6.ngx.x86_64                                1/1 

Installed:
  nginx.x86_64 0:1.14.0-1.el6.ngx                                               

Complete!

3 开启NGINX并测试。

[root@localhost yum.repos.d]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]

测试成功。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值