当前位置 主页 > 服务器问题 > Linux/apache问题 >

    Linux下安装配置nginx详解

    栏目:Linux/apache问题 时间:2019-10-12 19:11

    一、Linux下安装配置nginx

    第一次安装nginx,中间出现的问题一步步解决。

    用到的工具secureCRT,连接并登录服务器。

    1.1 rz命令,会弹出会话框,选择要上传的nginx压缩包。

    #rz 

    1.2 解压

    [root@vw010001135067 ~]# cd /usr/local/
    [root@vw010001135067 local]# tar -zvxf nginx-1.10.2.tar.gz

    1.3 进入nginx文件夹,执行./configure命令

    [root@vw010001135067 local]# cd nginx-1.10.2
    [root@vw010001135067 nginx-1.10.2]# ./configure

    报错如下:

    checking for OS
     + Linux 2.6.32-431.el6.x86_64 x86_64
    checking for C compiler ... not found
    
    ./configure: error: C compiler cc is not found
    

    出现这个错误。那么就是gcc 包没有安装。

    1.3.1 安装gcc

    查看gcc

    [root@vw010001135067 nginx-1.10.2]# whereis gcc
    gcc:

    安装gcc

    [root@vw010001135067 nginx-1.10.2]# yum -y install gcc

    安装成功后再次查看

    [root@vw010001135067 nginx-1.10.2]# whereis gcc
    gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

    gcc安装好了。

    1.3.2 继续执行./configure

    [root@vw010001135067 nginx-1.10.2]# ./configure
    checking for OS
     + Linux 2.6.32-431.el6.x86_64 x86_64
    checking for C compiler ... found
    ......
    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-devel

    [root@vw010001135067 nginx-1.10.2]# yum install pcre-devel

    1.3.3 再次执行./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.

    如果有这个错误 那么执行

    yum install zlib-devel

    1.3.4 执行./configure后没有报错

    [root@vw010001135067 nginx-1.10.2]# ./configure
    checking for OS
     + Linux 2.6.32-431.el6.x86_64 x86_64
    checking for C compiler ... found
     + using GNU C compiler
     + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
    .......
    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
    
     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"