---
title: "Ubuntu 14.04 LTS 安装 Nginx 1.6.1"
author: "stephen830"
date: "2014-08-30T20:41:54Z"
tags: []
categories: ["开源软件"]
slug: "ubuntu-14-04-lts-nginx-1-6-1"
draft: false
lastmod: "2014-08-30T20:41:54Z"
id: 2111129
url: "https://stephen830.iteye.com/blog/2111129"
---

Ubuntu 14.04 LTS 安装 Nginx 1.6.1

 

如果用apt-get安装了老版本的nginx，可以用apt-get purge nginx 命令删除已经安装老版本。

 

 

step 1 - 安装编译器

```
apt-get install build-essential  
apt-get install libtool  
```

 

接下来安装PCRE，zlib 和 SSL。参考网上的文档，下载的源码存放到目录 /usr/local/src

 

step 2 - 安装 PCRE， Perl Compatible Regular Expressions

```
从 pcre.org 找到并下载
tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make
make install
```

 

step 3 - 安装 zlib，用于对http包进行gzip压缩

```
从 zlib.net 找到并下载
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
```

 

step 4 - 安装openssl

```
从 openssl.org 找到并下载
tar -zxvf openssl-1.0.1i.tar.gz
```

 

step 5 - 安装Nginx

```
从 nginx.org 找到并下载最新稳定版
tar -zxvf nginx-1.6.1.tar.gz
cd nginx-1.6.1
sudo ./configure --conf-path=/usr/local/nginx1.6.1/nginx.conf --pid-path=/usr/local/nginx1.6.1/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1i
make
make install
```

 

step 6 - 启动nginx

```
#检查80端口是否被占用
netstat -ano |grep 80

#启动nginx
sudo /usr/local/nginx/sbin/nginx
```

 

在浏览器中访问 http://localhost，成功打开 Welcome to nginx 页面!!