1 配置yum源。
操作系统为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 ]
测试成功。