nginx安装与部署

总的来说,需要提前安装几个依赖模块:gzip需要的zlib库,rewrite模块需要的pcre库,ssl模块需要的openssl库,当然可能部分linux服务器上已经安装了上述模块中的一个或多个,安装时可以根据情况灵活处理。


1. 打开http://nginx.org/en/download.html, wget http://nginx.org/download/nginx-1.8.1.tar.gz
2. tar -zxvf nginx-1.8.1.tar.gz
3. mv nginx-1.8.1 /usr/local
4. cd /usr/local 
5. ln -s nginx-1.8.1 nginx
6. cd nginx
7. ./configure,出现./configure: error: the HTTP rewrite module requires the PCRE library...
8. 下载PCRE:wget http://downloads.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fpcre%2Ffiles%2Fpcre2%2F10.21%2F&ts=1457715675&use_mirror=jaist
9. unzip pcre-8.38.zip
10.mv pcre-8.38 /usr/local
11.cd /usr/local;
12.ln -s pcre-8.38 pcre
12.cd pcre
13../configure;make;make install
14.cd /usr/local/nginx; ./configure,发现:Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library


15.下载openssl:wget http://www.openssl.org/source/openssl-1.0.2g.tar.gz
16.tar -zxvf openssl-1.0.2g.tar.gz; mv openssl-1.0.2g /usr/local; cd /usr/local;ln -s openssl-1.0.2g openssl;cd openssl; ./config ;make;make install;
17.cd /usr/local/nginx; ./configure;仍然发现OpenSSL library is not used;然后执行 ./configure --with-openssl=/usr/local/openssl
18. /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf,提示找不到libpcre.so.1
19. ldd $(which /usr/local/nginx/sbin/nginx),发现/usr/local/lib下有libpcre.so.1 。 另外,/lib64下也有类似文件libpcre.so.0.0.1
20.cd /lib64; ln -s libpcre.so.0.0.1 libpcre.so.1

20.再执行,/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf,然后通过浏览器访问:http://ip访问,打开nginx欢迎页面,OK。


注意:有时安装到最后一步make install时,会发现cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file,主要原因就是/usr/local/nginx既是tar.gz解压后的目录,又是安装的目的目录,而如果目录重合的话,conf文件夹中的文件在从源目录拷贝到目的目录时会发现源和目的相同,所以提示错误。所以安装时最好是不要ln -s nginx-1.8.3 nginx,而是在nginx-1.8.3目录下执行configure,并指定prefix:./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-openssl=/usr/local/openssl --with-http_ssl_module ,如果没有"--with-http_ssl_module",则可能会报错:“unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:41”

参考文章:http://www.cnblogs.com/skynet/p/4146083.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值