zoukankan      html  css  js  c++  java
  • 安装nginx+lua开发环境

    一.安装nginx及搭建本地测试环境

    1.创建安装目录:    /data/nginx
    2.安装make:        yum-y install gcc automake autoconf libtool make
    3.安装gcc和g++:     yum install gcc gcc-c++
    4.安装Luajit(最新版):从http://luajit.org/download.html下载解压
           然后安装:      make && make install
    5.nginx的安装和配置

      从http://nginx.org/en/download.html(nginx官网)下载最新安装包
                    解压:  tar zxvf nginx-1.9.11.tar.gz

      在nginx目录下创建nginx-module目录
           在nginx-module目录下下载第三方模块:
           lua-nginx-module:
                    git clone https://github.com/chaoslawful/lua-nginx-module.git
           echo-nginx-module:
                    git clone https://github.com/agentzh/echo-nginx-module.git
           ngx_devel_kit:
                    git clone https://github.com/simpl/ngx_devel_kit.git
           在nginx目录下安装pcre和zlib:
                    到网站下载pcre-8.33.tar.gz和zlib-1.2.8.tar.gz
                    解压并安装:./configure && make && make install
           修改配置:
                进入nginx-1.9.11目录
                    ./configure --prefix=/data/nginx
                    --add-module=../nginx-module/lua-nginx-module
                    --add-module=../nginx-module/echo-nginx-module
                    --add-module=../nginx-module/ngx_devel_kit
                    --with-pcre=../pcre-8.33
                    --with-zlib=../zlib-1.2.8
            make && make install
    安装好以后在浏览器地址栏输入:localhost , 如果出现welcome to nginx则说明安装成功

    二.导入lua

    luajit默认安装在/user/local/lib目录下,但是nginx是从/user/lib 目录下去找luajit的,因此两种解决办法,一种是安装完成后手动cp luajit库移一下,另一种是安装nginx config前先导入环境变量,告诉nginx去哪里找luajit

    # export LUAJIT_LIB=/usr/local/lib

    # export LUAJIT_INC=/usr/local/include/luajit-2.0

    测试:

    vim /usr/example/lua/test.lua  
    1 #添加如下内容  
    2 ngx.say("hello world"); 

      然后修改conf下的nginx.conf(注意备份)

    1 #在server里添加
    2 location /test {  
    3     default_type 'text/html';  
    4     content_by_lua_file /usr/example/lua/test.lua;  
    5 } 

    在浏览器输入:localhost/test

      出现:hello world  

      nginx+lua环境就安装成功了

  • 相关阅读:
    ZOJ 1002 Fire Net
    Uva 12889 One-Two-Three
    URAL 1881 Long problem statement
    URAL 1880 Psych Up's Eigenvalues
    URAL 1877 Bicycle Codes
    URAL 1876 Centipede's Morning
    URAL 1873. GOV Chronicles
    Uva 839 Not so Mobile
    Uva 679 Dropping Balls
    An ac a day,keep wa away
  • 原文地址:https://www.cnblogs.com/victorwu/p/5210498.html
Copyright © 2011-2022 走看看