您的位置:首页 > 运维架构 > Nginx

Linux下nginx安装

2016-01-22 15:01 567 查看


centos直接yum安装nginx

Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便。
1.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

3,安装并启动nignx

[root@server ~]# yum install nginx

[root@server ~]# service nginx start

Starting nginx: [ OK ]

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

service nginx reload
nginx -s reload

nginx -t -c /usr/nginx/conf/nginx.conf

或者

nginx -t (推荐)



/usr/nginx/sbin/nginx -t
==============================

[html] view plaincopy




自动安装选择最快的源

[root@localhost ~]# yum install yum-fastestmirror

这里 我已经安装过,运行结果如下

[html] view plaincopy




Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

* base: ftp.riken.jp

* epel: mirrors.zju.edu.cn

* extras: ftp.riken.jp

* updates: ftp.riken.jp

Setting up Install Process

Package yum-plugin-fastestmirror-1.1.30-30.el6.noarch already installed and latest version

安装nginx

yum install nginx

[html] view plaincopy




[root@localhost ~]# yum install nginx

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

* base: ftp.riken.jp

* epel: mirrors.opencas.cn

* extras: ftp.riken.jp

* updates: ftp.riken.jp

Setting up Install Process

Package nginx-1.8.0-1.el6.ngx.x86_64 already installed and latest version

平滑升级

yum update nginx

执行命令前,首先配置nginx 源

[html] view plaincopy




[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo

[html] view plaincopy




#nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/6/$basearch/

gpgcheck=0

enabled=1

执行:yum update nginx

Complete!

[root@localhost ~]# service nginx stop

停止 nginx: [确定]

[root@localhost ~]# service nginx start

正在启动 nginx: [确定]

[root@localhost ~]# nginx -v

nginx version: nginx/1.8.0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: