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
或者
nginx -t (推荐)
或
/usr/nginx/sbin/nginx -t
==============================
- 自动安装选择最快的源
- [root@localhost ~]# yum install yum-fastestmirror
- 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
- [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 源
- [root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
- #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