[root@server yum.repos.d]# yum install nginx
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
163 packages excluded due to repository priority protections
Setting up Install Process
No package nginx available.
Error: Nothing to do

没法使用yum安装

百度之,找到的第一个答案是没有安装EPEL,则安装之

[root@server yum.repos.d]# rpm -Uvh ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
package epel-release-6-8.noarch is already installed

之后照样执行yum install nginx依然错误

之后发现这台机器上已经编译安装过nginx,找一台新机器,尝试后依然错误。

[root@localhost local]# yum info nginx
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.cug.edu.cn
 * extras: mirrors.cug.edu.cn
 * updates: mirrors.cug.edu.cn
Error: No matching Packages to list

经查询原来是没有nginx的yum源包

直接安装一个nginx的yum源文件

[root@localhost local]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Retrieving http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
warning: /var/tmp/rpm-tmp.y29UIV: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing...                ########################################### [100%]
   1:nginx-release-centos   ########################################### [100%]
[root@localhost local]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 20
-rw-r--r--. 1 root root 1926 12月  9 2011 CentOS-Base.repo
-rw-r--r--. 1 root root  637 12月  9 2011 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  626 12月  9 2011 CentOS-Media.repo
-rw-r--r--. 1 root root  113 10月 14 2011 nginx.repo
-rw-r--r--. 1 root root 1250 11月  8 17:40 puppetlabs.repo

就可以使用yum install nginx安装了

[root@localhost local]# yum install nginx
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.cug.edu.cn
 * extras: mirrors.cug.edu.cn
 * updates: mirrors.cug.edu.cn
nginx                                                                                                                                                                                                                | 2.9 kB     00:00     
nginx/primary_db                                                                                                                                                                                                     |  34 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.6.2-1.el6.ngx will be installed
--> Processing Dependency: openssl >= 1.0.1 for package: nginx-1.6.2-1.el6.ngx.x86_64
--> Processing Dependency: libz.so.1(ZLIB_1.2.0)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
--> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
--> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
--> Running transaction check
---> Package openssl.x86_64 0:1.0.0-20.el6 will be updated
--> Processing Dependency: openssl = 1.0.0-20.el6 for package: openssl-devel-1.0.0-20.el6.x86_64
---> Package openssl.x86_64 0:1.0.1e-30.el6_6.4 will be an update
---> Package zlib.x86_64 0:1.2.3-27.el6 will be updated
--> Processing Dependency: zlib = 1.2.3-27.el6 for package: zlib-devel-1.2.3-27.el6.x86_64
---> Package zlib.x86_64 0:1.2.3-29.el6 will be an update
--> Running transaction check
---> Package openssl-devel.x86_64 0:1.0.0-20.el6 will be updated
---> Package openssl-devel.x86_64 0:1.0.1e-30.el6_6.4 will be an update
---> Package zlib-devel.x86_64 0:1.2.3-27.el6 will be updated
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================================================
 Package                                                    Arch                                                Version                                                          Repository                                            Size
============================================================================================================================================================================================================================================
Installing:
 nginx                                                      x86_64                                              1.6.2-1.el6.ngx                                                  nginx                                                336 k
Updating for dependencies:
 openssl                                                    x86_64                                              1.0.1e-30.el6_6.4                                                updates                                              1.5 M
 openssl-devel                                              x86_64                                              1.0.1e-30.el6_6.4                                                updates                                              1.2 M
 zlib                                                       x86_64                                              1.2.3-29.el6                                                     base                                                  73 k
 zlib-devel                                                 x86_64                                              1.2.3-29.el6                                                     base                                                  44 k
Transaction Summary
============================================================================================================================================================================================================================================
Install       1 Package(s)
Upgrade       4 Package(s)
Total size: 3.1 M
Total download size: 3.0 M
Is this ok [y/N]: n