Debian 8 Jessie如何安装Nginx1.9.5

Nginx1.9.5版本于2015年9月22日发布,属于mainline版本,而Nginx 1.8属于stable版本。Nginx官方推荐优先使用mainline版本。如果你担心mainline版本与第三方模块存在兼容问题,或者你总是担心mainline版本中会有bug,那么stable版本更加适合您。这篇文章将介绍如何在Debian 8 Jessie服务器上安装Nginx 1.9.5。

安装过程

首先,删除旧的Nginx版本:

sudo apt-get remove nginx nginx-common nginx-full

安装Nginx团队的PGP签名钥匙:

wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

然后将下面两行添加到/etc/apt/sources.list文件的末尾:

deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx

更新软件源并安装最新版的Nginx

sudo apt-get update
sudo apt-get install nginx

在安装的过程中,可以选择使用原来的配置文件/etc/nginx/nginx.conf或使用新安装的配置文件,如果你选择使用新的配置文件,那么要先备份旧的配置文件,以备参考。

sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old

安装完成后,可以输入下面的命令来查看当前版本

user@host:~$ curl -I http://www.example.com
HTTP/1.1 200 OK
Server: nginx/1.9.5
Date: Fri, 02 Oct 2015 14:08:26 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive

将www.example.com换成自己的域名。

也可以用sudo nginx -v命令

user@host:~$ sudo nginx -v
nginx version: nginx/1.9.5
为这篇文章评分
[Total: 1 Average: 5]

Leave a Reply

Your email address will not be published.

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here