手机版 欢迎访问it开发者社区(www.mfbz.cn)网站

当前位置: > 开发

腾讯云centos6.9安装nginx实践

时间:2021/4/29 22:36:47|来源:|点击: 次

腾讯云centos6.9安装nginx实践

安装步骤

#1.先下载tag包
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.14.2.tar.gz
#2.解压缩
tar zxvf nginx-1.14.2.tar.gz
#3.进入解压目录 配置 安装安装到/usr/local/nginx 目录上
cd nginx-1.14.2
./configure --prefix=/usr/local/nginx


安装出错1.

[root@VM-16-13-centos nginx-1.14.2]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 2.6.32-754.30.2.el6.x86_64 x86_64
checking for C compiler ... not found

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

没有装gcc 先yum 装下gcc

yum install gcc
#yum install 出现错误,省略了部分错误信息
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge.

yum install 命令执行错误 在网上寻找答案 腾讯云默认的yum 源文件是有问题的需要去修改下
将 /etc/yum.repos.d/CentOS-Base.repo 和 /etc/yum.repos.d/CentOS-Epel.repo 中的 $releasever 替换成 6 这个6值为centos 大版本号,修改文件保存后在执行 yum install gcc 可正常执行, 腾讯云重装系统n次后yum install 未发现这个问题真是奇怪…

接着接续安装

./configure --prefix=/usr/local/nginx

安装出错2.

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 库 那就安装这个库

yum -y install pcre-devel

安装完ok接着安装nginx

./configure --prefix=/usr/local/nginx

出现问题3

checking for PCRE JIT support ... not found
checking for zlib library ... not found

./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库 那就咱们接着安装

cd /usr/local/src
# 下载zlib 包
wget http://www.zlib.net/zlib-1.2.11.tar.gz
#解压
tar -xzvf zlib-1.2.11.tar.gz
# 编译安装
./configure
make
make install

安装ok继续安装nginx

./configure --prefix=/usr/local/nginx

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

  #再进行编译安装
  make && make install

总算是安装成功

这是本人安装nginx 过程的分享,如若哪部分书写的有问题,请评论反馈

Copyright © 2002-2019 某某自媒体运营 版权所有