---
title: "Linux nginx 安装"
author: "lwlnuligongzuo"
date: "2012-07-20T16:51:36Z"
tags: ["nginx"]
categories: ["研发管理"]
slug: "linux-nginx"
draft: false
lastmod: "2013-09-16T15:36:06Z"
id: 1602289
url: "https://chongzai.iteye.com/blog/1602289"
---

**全新安装**

1.先下载nginx和相关依赖包

- nginx     [http://nginx.org/en/download.html](http://nginx.org/en/download.html)
- pcre       [http://www.pcre.org/](http://www.pcre.org/)
- zlib        [http://zlib.net/](http://zlib.net/)(这个好像被\*墙\*了,我上传了一个,其他都可以到官网下载)
- openssl [http://www.openssl.org/](http://www.openssl.org/)

2.编译命令(其实依赖只需要解压不需要安装)

```
sudo ./configure --prefix=/usr/nginx --with-http_stub_status_module --with-http_ssl_module  --with-pcre=/app/pcre-8.20 --with-zlib=/app/zlib-1.2.5 --with-openssl=/app/openssl-1.0.0g
```

 3.安装

```
make && make install
```

 

 

**如果你是已经安装好的nginx现在需要添加一个未被编译安装的模块**

可以用nginx -V 查看原来编译时都带了哪些参数

然后添加新的参数重新编译

 

1\. 使用参数重新配置:

```
./configure --prefix=/app/nginx --with-http_stub_status_module \
--with-http_ssl_module --with-http_realip_module \
--add-module=../nginx_upstream_hash-0.3.1/ \
--add-module=../gnosek-nginx-upstream-fair-2131c73/
```

 

2\. 编译:

    

```
make 千万不要make install，否则就是覆盖安装
```

 

3\. 替换nginx二进制文件:

```
cp /app/nginx/sbin/nginx /app/nginx/sbin/nginx.bak
cp ./objs/nginx /app/nginx/sbin/
```