zoukankan      html  css  js  c++  java
  • nginx安装

    一、下载安装包

    1.下载nginx安装包

    wget http://nginx.org/download/nginx-1.10.3.tar.gz
    

      

    2.下载NDK安装包

    wget https://github.com/simpl/ngx_devel_kit/tarball/master -O ngx_devel_kit.tar.gz
    

      

    3.下载LuaJIT安装包

    wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
    

      

    4.下载ngx-lua模块

    wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz -O lua-nginx-module-0.10.13.tar.gz
    

      

    5.其他ngx第三方模块

    #ngx支持断点续传模块
    #nginx-upload-module此版本太新,如果make出错就用下面的那个
    wget https://github.com/fdintino/nginx-upload-module/archive/2.2.0.tar.gz -O nginx-upload-module-2.2.0.tar.gz
    
    #nginx-upload-module老版本
    wget https://github.com/hongzhidao/nginx-upload-module/archive/master.zip
    
    
    #清除静态缓存模块
    wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
    

      

    二、前置安装

    1. 创建nginx worker进程的运行用户

    groupadd -g  1001 nginx
    useradd -g 1001 -u 1001 -s /sbin/nologin nginx
    

      

    2. 检测系统安装包

    #检测是否有gcc编译器
    rpm -qa | grep gcc  || yum install gcc
    
    #检测是否有openssl-devel,ngx依赖此安装包来支持ssl功能
    rpm -qa | grep openssl-devel  || yum install openssl-devel
    
    #检测是否有pcre-devel,ngx依赖此安装包来支持rewrite功能
    rpm -qa | grep pcre-devel  || yum install pcre-devel
    
    #检测是否有gd-devel,ngx依赖此安装包来支持图片处理功能
    rpm -qa | grep gd-devel  || yum install gd-devel
    
    #安装LuaJit解释器,ngx需此解释器解释lua代码
    tar -xzf LuaJIT-2.0.5.tar.gz
    cd LuaJIT-2.0.5
    make && make install  

    安装LuaJIT时注意制定目录,要不然其他nginx报错

    make install PREFIX=/usr/local/luajit

    三、安装步骤

    #解压相关安装包
    tar -xzf *.tar.gz
    
    #编译安装
    cd nginx-1.10.3
    ./configure --prefix=/usr/local/nginx --with-stream --with-http_stub_status_module --with-http_image_filter_module --with-http_ssl_module --user=nginx --group=nginx --with-pcre --add-module=../simplresty-ngx_devel_kit-a22dade/ --add-module=../ngx_cache_purge-2.3 --add-module=../lua-nginx-module-0.10.13  --add-module=../nginx-upload-module-2.2.0
    make 
    make install
    

      

    如果make报错openssl,那么有可能openssl升级过,请找到升级后的openssl路径,如下(增加): 

    先查找下openssl的位置:find / -name openssl*,得到地址后,增加如下 

    ./configure --prefix=/usr/local/nginx2 --with-stream --with-openssl=/root/openssl-1.0.1g --with-http_stub_status_module --with-http_image_filter_module --with-http_ssl_module --user=nginx --group=nginx --with-pcre --add-module=../simplresty-ngx_devel_kit-a22dade/ --add-module=../ngx_cache_purge-2.3 --add-module=../lua-nginx-module-0.10.13 --add-module=../nginx-upload-module-master

    安装完nginx后,检查nginx:

    /usr/local/nignx/sbin/nginx -t 

    如果没错,就继续往下执行,如果有报错,报错如下:

    ./sbin/nginx -t
    如果出现error:
     error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such fil 

    解决方案:

    export LD_LIBRARY_PATH=/usr/local/luajit/lib:$LD_LIBRARY_PATH
    
    从新编译编译 luajit的时候 make install PREFIX=/usr/local/luajit
    

      

    安装好后,执行,要不然启动,报找不到pid

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    

      

    nginx.conf配置,其他的默认注意这里面的,php配置,端口监听,http/ip配置即可:

     server {
            listen       81;
            server_name  192.168.2.66;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   /home/html2/;
                index  index.html index.htm index.php;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            #location = /50x.html {
            #    root   html;
            #}
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            location ~ .php$ {
                root           /home/html2/;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                #include        fastcgi_params;
    	    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;	
            }
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /.ht {
            #    deny  all;
            #}
        }
    

      

     

     

  • 相关阅读:
    python print format
    ElasticSearch的lowlevelApi和低级别API
    Ubuntu下搜狗输入法突然无法输入中文
    mysql基本操作
    eclipse配置代码自动提示
    使用JAAS登录kerberos服务器
    centos7配置kerberos服务,并使用JAAS登录
    LDAP none、simple、strong 笔记
    linux下yum安装最新稳定版nginx
    Mybatis if标签判断大小
  • 原文地址:https://www.cnblogs.com/achengmu/p/8954057.html
Copyright © 2011-2022 走看看