---
title: "Ubuntu上安装nginx"
author: "stephen830"
date: "2014-06-26T23:14:39Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu-nginx"
draft: false
lastmod: "2015-04-27T18:14:25Z"
id: 2085810
url: "https://stephen830.iteye.com/blog/2085810"
---

方法1: 直接用apt-get安装

 

apt-get install nginx-full

 

安装后的nginx.conf位置 /etc/nginx/nginx.conf

 

 

方法2:用源码编译

 

首先解压

```
cd /root

tar -zxvf nginx-1.6.0.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
tar -zxvf openssl-1.0.1.tar.gz
tar -zxvf pcre-8.35.tar.gz
```

 

然后进入目录 cd /root/nginx-1.6.0 开始安装

 

```
--prefix=/usr/local/nginx-1.6.0
```

安装好后，nginx的工作目录。

 

```
--with-pcre=/root/pcre-8.35
```

pcre的源代码目录

 

```
--with-openssl=/root/openssl-1.0.1
```

openssl的源代码目录

 

```
--with-zlib=/root/zlib-1.2.8
```

zlib的源代码目录

 

 

进入上面解压后的nginx-1.6.0目录，执行./configure

（如果没有编译环境，请执行 sudo apt-get install build-essential ，安装gcc编译环境。）

 

```
./configure --prefix=/usr/local/nginx-1.6.0 --with-http_ssl_module --with-ld-opt="-L /usr/local/lib" --with-pcre=/root/pcre-8.35 --with-openssl=/root/openssl-1.0.1 --with-zlib=/root/zlib-1.2.8
```

 

然后在执行

make

make install

 

如果make时候遇到错误：POD document had syntax errors at /usr/bin/pod2man line 71.

则看下是否有文件： /usr/bin/pod2man

如果存在这个文件，则将其备份后将其删除，rm /usr/bin/pod2man

然后重新make