首页 > 代码库 > Centos7安装nginx

Centos7安装nginx

<style>pre,code,tt { font-size: 12px; font-family: Consolas, "Liberation Mono", Courier, monospace } code,tt { margin: 0 0px; padding: 0px 0px; white-space: nowrap; border: 1px solid #eaeaea; background-color: #f8f8f8 } pre>code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent } pre { background-color: #f8f8f8; border: 1px solid #ccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px } pre code,pre tt { background-color: transparent; border: none } kbd { background-color: #DDDDDD; background-image: linear-gradient(#F1F1F1, #DDDDDD); background-repeat: repeat-x; border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD; border-style: solid; border-width: 1px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 10px; padding: 1px 4px }</style>

下载、安装

  • 依次执行下列命令:

    `
    cd /usr/local/src/
    
    wget http://nginx.org/download/nginx-nginx-1.10.1.tar.gz
    
    tar zxvf nginx-1.10.1.tar.gz -C /usr/local
    
    cd /usr/local/nginx-1.10.1/
    
    ./configure
    
    `
    
  • 问题:

./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-httprewritemodule option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option

安装依赖

$ yum install gcc-c++
$ yum install pcre pcre-devel
$ yum install zlib zlib-devel
$ yum install openssl openssl--devel

再次安装nginx

cd /usr/local/nginx-1.10.1/ ./configure make && make install

测试是否可用

cd /usr/local/nginx/sbin ./nginx

  • 如果出现如下问题: ` nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] still could not bind()

    `

  • 查看80端口占用情况

netstat -ntpl pkill -9 nginx 再次启动./nginx

  • 也有可能是防火墙的问题,查看ip是否可以ping通,端口是否开放

升级python后导致yum不可用

vi /usr/bin/yum

修改python头部python为python2.7.5

 

Centos7安装nginx