首页 > web > nginx

centos中yum安装nginx
时间:2014-03-10 14:25:40  点击: 来源:  作者:

Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便。但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流程,也十分简单:1、CentOS 6,先执行:
rpm -ivh http://nginx.org/package ...

Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便。

但是今天装了CentOS6.2,直接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
2,查看yum的nginx信息

 

# yum info nginx

 

Loaded plugins: fastestmirror
......

 


3,安装并启动nignx
[root@server ~]# yum install nginx
[root@server ~]# service nginx start
Starting nginx:                                            [  OK  ]

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

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

 恭喜你,你成功了!

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


如果无法安装,请参考下面:

1.为了追加 nginx 的 yum 仓库,需要创建一个文件 /etc/yum.repos.d/nginx.repo,并将下面的内容复制进去: 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
2.编辑并保存/etc/yum.repos.d/nginx.repo文件后,在命令行下执行 
[root@localhost ~]# yum list | grep nginx
nginx.i386                               1.4.7-1.el6.ngx               @nginx   
nginx-debug.i386                         1.4.7-1.el6.ngx               nginx
会发现就是最新的稳定版 
于是直接执行 
yum -y install nginx
安装即可 
3.这种安装和从源代码编译Nginx的安装完全不一样,安装完执行下面的命令 
[root@localhost ~]# find / -name *nginx*
/etc/nginx/nginx.conf
[root@localhost ~]# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
你会发现主要文件安装到了/etc/nginx下 
接下来是启动Nginx服务,可以执行 
[root@localhost ~]# service nginx start
正在启动 nginx:                                           [确定]
启动成功。 
 
4.设置开机自动启动 
在centos6.5下测试了一下,不用设置 
chkconfig nginx on 
可以自行开机自动启动 

”您可通过以下微信二维码,赞赏作者“
 
 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
linux服务器同步互联网时间
linux服务器同步互联
亚马逊云lightsail服务器使用教程 | 亚马逊云lightsail使用指南
亚马逊云lightsail服
hostdare 4折优惠,直接降价60% 美国洛杉矶低至 $10.4/年 768M内存/1核/10gNVMe/500g流量
hostdare 4折优惠,直接
六类网线cat6a和cat6e的区别
六类网线cat6a和cat6e
相关文章
栏目更新
栏目热门

关于我们 | 广告服务 | 联系我们 | 网站地图 | 免责声明 | WAP | RSS


Copyright © 运维之家 2013-2023