(原创)Nginx的配置及安装一(centos6.5下)

1. 从 http://nginx.org/en/download.html 获取可用的版本,一般情况下我们会找一个稳定的版本来下载,2015年3月份的时候,我们能看到的稳定版本就是这个nginx-1.6.2.tar.gz,如下图所示:

1

2. 通过wget命令获取到安装代码,命令如下:wget -c http://nginx.org/download/nginx-1.6.2.tar.gz

3. 下载完成以后通过tar zxvf xxx.tgz解压,生成nginx目录;

4. 在这个目录下执行./configure,但是一般情况下,系统都会因为某些库没有安装,导致不能成功,目前总结的大概有如下三种情况:

(1)

./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 -y install pcre-devel

(2)

./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.

这种情况下一般需要执行如下命令,安装zlib库:

yum -y install zlib-devel

(3)

./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

这种情况下一般需要执行如下命令,安装openssl库:

yum -y install openssl openssl-devel

5. 执行./configure.基本上到这里就通过了,配置完成,下面就是配置多站点了。

checking for C compiler ... not found

yum -y install gcc
yum -y install gcc-c++
yum install make