首先找到Nginx下载官网:http://nginx.org/en/download.html
看到内容如下:
nginx: download | english русский 简体中文 עברית 日本語 türkçe news about download security advisories documentation pgp keys faq links books support donation trac wiki nginx.com | ||||||||||||||||||||
Development version
Stable version
Legacy versions
Source CodeRead-only Subversion repositories:
Read-only Mercurial repositories:
Pre-Built Linux Packages for StableTo enable automatic updates of Linux packages set up the yum repository for the RHEL/CentOS distributions, or the apt repository for the Debian/Ubuntu distributions. To set up the yum repository for RHEL/CentOS, choose the corresponding This package contains yum configuration file and a public PGP key necessary to authenticate signed RPMs. Download and install it, then run the following: yum install nginx Alternatively, a repository configuration can be added manually without installing the [nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1 Replace “ |
让我们重点关注如下描述:
Pre-Built Linux Packages for Stable
To enable automatic updates of Linux packages set up the yum repository for the RHEL/CentOS distributions, or the apt repository for the Debian/Ubuntu distributions.
To set up the yum repository for RHEL/CentOS, choose the corresponding nginx-release
package from the list:
This package contains yum configuration file and a public PGP key necessary to authenticate signed RPMs. Download and install it, then run the following:
yum install nginx
Alternatively, a repository configuration can be added manually without installing the nginx-release
package. Create the file named /etc/yum.repos.d/nginx.repo
with the following contents:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
Replace “OS
” with “rhel
” or “centos
”, depending on the distribution used, and “OSRELEASE
” with “5
” or “6
”, for 5.x or 6.x versions, respectively.
方式一
点击“CentOS 6”这个链接下载一个rpm文件,然后安装之
>wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
>rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
这个rpm并非完整的nginx,而是contains yum configuration file and a public PGP key necessary to authenticate signed RPMs。意思是说这个rpm安装完成后已经添加了响应的yum配置信息文件和对rpm进行签名使用的公钥。
安装玩这个包后我们执行如下命令查看yum的respo文件:
不难发现/etc/yum.repos.d目录下多了一个nginx.repo文件,这个文件存放的是nginx的repository 配置。这个文件之前是没有的。查看这个文件的内容:
接下来使用如下命令真正安装nginx:
>yum install nginx -y
方式二
手动创建一个文件/etc/yum.repos.d/nginx.repo
>touch /etc/yum.repos.d/nginx.repo
编辑文件内容为:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
接下来使用如下命令查看可以安装的nginx rpm资源
安装之
查看nginx是否安装成功
>which nginx
查看nginx帮助信息
>nginx -h
查看nginx版本
>nginx -V
启动nginx
>nginx
通过查看端口判断启动是否成功
>netstat -antp|grep nginx
通过浏览器访问也可以判断是否安装成功:
http://serverip/
出现以下内容表示成功!!!
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.