离线CentOS 6.8 64Bit 安装 NGINX

最近公司服务器新平台迁移,需要重新部署服务器,由于是政务内网,安装NGINX也是一番踩坑记录,在此记录一下。

(一):下载nginx的 .tar.gz包,地址:https://nginx.org/en/download.html 

我使用的是1.8版本的nginx

下载完 上传到服务器
 a:解压 tar包  执行    : tar zxvf nginx-1.8.1.tar.gz 

 b:cd nginx-1.8.1  执行 : ./configure
报错:./configure: error: the HTTP rewrite module requires the PCRE library. 上网搜索是缺少pcre依赖,那就下载PCRE tar包

地址:https://sourceforge.net/projects/pcre/

同样下载完上传到服务器。

解压  执行  :  tar zxvf pcre-8.43.tar.gz   ,进到解压完的pcre目录

配置:执行 ./configure

再次出现错误:找不到  gcc-c++ ,查看服务器 gcc 版本 : 

[root@debug010000002015 datahome]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ,可以看到 gcc版本为:4.4.7,那就下载个同版本的gcc-c++

下载地址:http://ftp.gnu.org/gnu/gcc/

下载完上传到服务器,并安装,执行 : rpm -ivh gcc-c++-4.4.7-17.el6.x86_64.rpm 
这里还踩到其他坑,参考:https://blog.csdn.net/cookiesoe/article/details/54584378,很感谢这位博主的文章

接下来一切安装就绪,再次去编译pcre
配置pcre :  执行    ./configure          编译并安装 : make && make install 

接下来 开始再次配置 nginx  执行  :  ./configure
再次出错  :./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.

(b)那就继续安装zlib 

还是到 :http://ftp.gnu.org/gnu/gcc/下载,然后上传到服务器 

安装执行 :  rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm 

再次./configure 一切顺利 ,
编译 :make
安装:make install
这次终于一切顺利,没有出现 error

下面查找nignx安装目录 :whereis nginx 

进到启动目录 :cd /usr/local/nginx/sbin/     执行:./nginx

再次出错:./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

如果机器是64位 执行 : ln -s /usr/local/lib/libpcre.so.1 /lib64

参考 : http://www.qttc.net/201208194.html

至此,一切安装完成

关闭 nignx : ./nginx -s stop

配置nignx,开机自启:vim /etc/rc.local ,增加/usr/local/nginx/sbin/nginx


  记录的比较乱,也就是给自己做下记录了,其实离线安装出现的问题,大部分都是缺少依赖或编译库,在这个网站上基本上都能找到满足的版本 : http://vault.centos.org/6.8/os/x86_64/Packages/


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值