/ 中存储网

CentOS系统使用yum方式安装Nginx服务器

2014-03-06 10:27:01 来源:kejihao
Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便。

但是今天装了CentOS6.3,直接yum install nginx不行,要先处理下源,下面是安装完整流程,也十分简单:

1,我的是CentOS 6,先执行:

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

如果是CentOS 5,就用下面的源:

rpm -ivh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm

如果是Red Hat Enterprise Linux 6:

rpm -ivh http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm

如果是Red Hat Enterprise Linux 5:

rpm -ivh http://nginx.org/packages/rhel/5/noarch/RPMS/nginx-release-rhel-5-0.el5.ngx.noarch.rpm

2,查看yum的nginx信息

[[email protected] ~]# yum info nginx

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * addons: mirror.yongbok.net

 * base: mirror.yongbok.net

 * contrib: mirror.yongbok.net

 * epel: mirrors.sohu.com

 * extras: mirror.yongbok.net

 * updates: centosk3.centos.org

epel                                   | 3.7 kB     00:00

epel/primary_db                        | 3.0 MB     00:12

Available Packages

Name       : nginx

Arch       : i386

Version    : 0.8.54

Release    : 1.el5

Size       : 390 k

Repo       : epel

Summary    : Robust, small and high performance HTTP and reverse proxy server

URL        : http://nginx.net/

License    : BSD

Description: Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and

           : IMAP/POP3 proxy server written by Igor Sysoev.

3,安装并启动nignx

[[email protected] ~]# yun install nignx

[[email protected] ~]# service nginx start

Starting nginx:                          [  OK  ]

4,然后进入浏览器,输入http://192.168.0.161/测试,如果看到

CentOS yum安装nginx - mango - 屋基坡公爵

 恭喜你,你成功了! 如果不能连接到nginx,原因很多,但是可以先检查 1,nginx服务是否真的起来了;2,linux服务器防火墙是否打开......