# centos安装nginx过程


1. 下载最新的nginx包（编译安装，个人喜欢新版本），下载包

2.   `./configure: error: C compiler cc is not found`

   由于默认缺少编译器，所以需要安装一些，还有依赖的依赖类似这种，反正不只是c编译器，执行 `yum install gcc gcc-c++ ncurses-devel perl`

3. ```
   ./configure: error: the HTTP rewrite module requires the PCRE library.
   You can either disable the module by using --without-http_rewrite_module
   option, or install the PCRE library into the system, or build the PCRE library
   statically from the source with nginx by using --with-pcre=<path> option.
   ```

   好了，继续缺PCRE库，支持伪静态。 

   `yum install pcre-devel`  btw: "-devel" 是开发版的意思

4. 继续

   ```
   ./configure: error: the HTTP gzip module requires the zlib library.
   You can either disable the module by using --without-http_gzip_module
   option, or install the zlib library into the system, or build the zlib library
   statically from the source with nginx by using --with-zlib=<path> option.
   ```

   Gzip 要求 zlib库

   `yum install zlib-devel` 错了， 应该 加-y，都没悬念的东西，免得需要确认。

   `yum -y install zlib-devel`

5. `make && make install`

6. 配置环境变量，建议改用户下面的 `vim ~/.bash_profile` 我不咋会用vim ， 更喜欢 `nano ~/.bash_profile` 添加下面两行

   ```
   export NGINX_HOME=/usr/local/nginx
   export PATH=$PATH:$NGINX_HOME/sbin
   ```

   然后 `source ~/.bash_profile` 使其生效

7. `nginx -v`
