#yum install nginx
补充:
如果遇到以下错误提示:
[root@localhost ~]# yum -y install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: data.nicehosting.co.kr
Setting up Install Process
No package nginx available.
Nothing to do
原因是:
对CentOS系统而言,Nginx不在标准库里,不过可以使用EPEL库,EPEL参考资料(http://www.cyberciti.biz/faq/rhel-fedora-centos-linux-enable-epel-repo/ )。 使用EPEL库安装Nginx,命令如下:
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
检查一下 yum list:
#yum repolist
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: data.nicehosting.co.kr
repo id repo name status
addons CentOS-5 - Addons enabled: 0
base CentOS-5 - Base enabled: 3,434
extras CentOS-5 - Extras enabled: 303
updates CentOS-5 - Updates enabled: 919
repolist: 4,656
如果没有 EPEL, 运行:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
版本号需要调整, 如果找不到。
[root@localhost ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
Retrieving http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
error: skipping http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm - transfer failed - Unknown or unexpected error
[root@localhost ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Retrieving http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.2DN7ju: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
再检查一下 yum list,
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* epel: ftp.sjtu.edu.cn
* extras: centos.ustc.edu.cn
* updates: data.nicehosting.co.kr
epel | 3.7 kB 00:00
epel/primary_db | 3.3 MB 00:15
repo id repo name status
addons CentOS-5 - Addons enabled: 0
base CentOS-5 - Base enabled: 3,434
epel Extra Packages for Enterprise Linux 5 - x86_64 enabled: 5,832
extras CentOS-5 - Extras enabled: 303
updates CentOS-5 - Updates enabled: 919
repolist: 10,488
如果 EPEL 更新成功, 则运行:
#yum install nginx