CentOS上 安装Nginx

首先找到Nginx下载官网:http://nginx.org/en/download.html

看到内容如下:

nginx

nginx: download


english
русский

简体中文
עברית
日本語
türkçe

news
about
download
security advisories
documentation
pgp keys
faq
links
books
support
donation

trac
wiki
twitter
nginx.com
Development version
CHANGESnginx-1.3.13  pgpnginx/Windows-1.3.13  pgp
Stable version
CHANGES-1.2nginx-1.2.7  pgpnginx/Windows-1.2.7  pgp
Legacy versions
CHANGES-1.0nginx-1.0.15  pgpnginx/Windows-1.0.15  pgp
CHANGES-0.8nginx-0.8.55  pgpnginx/Windows-0.8.55  pgp
CHANGES-0.7nginx-0.7.69  pgpnginx/Windows-0.7.69  pgp
CHANGES-0.6nginx-0.6.39  pgp 
CHANGES-0.5nginx-0.5.38  pgp 
Source Code

Read-only Subversion repositories:

  • code: svn://svn.nginx.org/nginx

Read-only Mercurial repositories:

  • site: http://hg.nginx.org/nginx.org

Trac source browser

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.


让我们重点关注如下描述:

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.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值