1、下载
到http://nginx.org/download/选择需要的版本,复制其连接地址。然后输入指令
marco@marco:~/download$ wget http://nginx.org/download/nginx-1.7.1.tar.gz
--2014-06-15 09:23:58-- http://nginx.org/download/nginx-1.7.1.tar.gz
Resolving nginx.org (nginx.org)... 206.251.255.63
Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 811015 (792K) [application/octet-stream]
Saving to: `nginx-1.7.1.tar.gz'
100%[======================================>] 811,015 233K/s in 3.4s
2014-06-15 09:24:11 (233 KB/s) - `nginx-1.7.1.tar.gz' saved [811015/811015]
随后解压
marco@marco:~/download$ tar -xvzf nginx-1.7.1.tar.gz
之后在当前目录下就会出现 nginx-1.7.1的目录。
2、检查
marco@marco:~/download/nginx-1.7.1$ ./configure
随后出现错误提示
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./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的全名是Perl Compatible Regular Expressions,是perl库,只要是让perl语言兼容正则表达式。
从错误提示看一看出来,如果没有这个库的话nginx 就无法支持HTTP的URL重写功能。不需要这个功能就可以在执行编译脚本的时候加上“--without-http_rewrite_module”参数就可以了。但是我还想要解决这个问题。
用http访问http://sourceforge.net/projects/pcre/files/pcre/,选择想要的PCRE版本下载。然后上传到服务器上。
加压、编译和安装PCRE
marco@marco:~/download$ tar -xvzf _pcre-8.35.tar.gz
marco@marco:~/download$ cd pcre-8.35/
marco@marco:~/download/pcre-8.35$ ./configure
marco@marco:~/download/pcre-8.35$ sudo make install