---
title: "Nginx安装"
author: "crane.ding"
date: "2014-04-07T11:43:26Z"
tags: ["nginx"]
categories: ["互联网"]
slug: "nginx"
draft: false
lastmod: "2014-04-07T11:43:26Z"
id: 2041744
url: "https://crane-ding.iteye.com/blog/2041744"
---

Nginx的了解和下载请看[百度百科-Nginx](http://baike.baidu.com/link?url=dflTB-OZObPOddnsWrBcKdvhlzA-KVGQHdAZV95bh9LeUbCD9DnoE1WX1AevNYxQ)和[Nginx官网](http://nginx.org/),这里主要是讲其安装的步骤。
        Nginx基本会用到的模块有rewrite、gzip和ssl，这三个模块都是需要安装相关依赖的包，rewrite需要先安装[pcre](http://www.pcre.org/)、gzip需要先安装[zlib](http://www.zlib.net/)、ssl需要先安装[openssl](http://www.openssl.org/)。这里就以[pcre-8.34](http://jaist.dl.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.bz2)、[zlib-1.2.8](http://zlib.net/zlib-1.2.8.tar.gz)和[openssl-1.0.0l](http://www.openssl.org/source/openssl-1.0.0l.tar.gz)、[nginx-1.4.7](http://nginx.org/download/nginx-1.4.7.tar.gz)版本为例子来讲解其安装步骤。


**  1. pcre的安装**


```shell

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.bz2
tar -xvf pcre-8.34.tar.bz2
cd pcre-8.34
./configure
make
make install 

```


**  2. pcre的安装**


```shell

wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure
make
make install

```


**  3. openssl的安装**


```shell

wget http://www.openssl.org/source/openssl-1.0.0l.tar.gz
tar -zxvf openssl-1.0.0l.tar.gz
cd openssl-1.0.0l
./configure
make
make install

```


**  4. nginx的安装**


```shell

wget http://nginx.org/download/nginx-1.4.7.tar.gz
tar -zxvf nginx-1.4.7.tar.gz
cd nginx-1.4.7/
./configure --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/src/openssl-1.0.0l
make
make install
# --with-openssl=/usr/src/openssl-1.0.0l 这里指的是openssl的源代码目录,即刚刚下载openssl的目录

```


**  5. nginx的启动**


```shell

cd /usr/local/nginx/sbin
./nginx
# Nginx默认的安装目录是/usr/local/nginx

```