Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2317156
  • 博文数量: 168
  • 博客积分: 3184
  • 博客等级: 中校
  • 技术积分: 3959
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-12 18:57
文章存档

2019年(1)

2018年(2)

2017年(3)

2016年(15)

2015年(10)

2014年(60)

2011年(1)

2010年(76)

分类: 系统运维

2016-12-16 17:45:56

# nginx_lua 安装

##1.安装lua, luajit, pcre, libevent

```shell

-- brew install lua

-- brew install luajit

-- brew install pcre

-- brew install libevent

```

##2.配置lua

```

 export LUAJIT_LIB=/usr/local/lib 

 

 //配置LUAJIT_INC  注意要写清楚版本号并且确认版本号是否存在 (强烈注意)

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

```

##3.下载开发插件

```

wget

wget https://codeload.github.com/simpl/ngx_devel_kit/zip/v0.3.0

tar zxvf lua-nginx-module-0.10.5.tar.gz

tar zxvf ngx_devel_kit-0.3.0.zip

```

##4.安装nginx

```

wget

tar zxvf nginx-1.10.1.tar.gz

cd nginx-1.10.1

./configure --add-module=/Users/dd/Downloads/source/nginx_lua --add-module=/Users/dd/Downloads/source/ngx_devel_kit

sudo make

sudo make install

```

##4.hello world

```shell

makedir  -p ~/openresty_test/nginx/conf

makedir  -p ~/openresty_test/nginx/log

cd ~/openresty_test/nginx/conf

vim nginx.conf

```

```conf文件

worker_processes  1;        #nginx worker 数量

error_log logs/error.log;   #指定错误日志文件路径

events {

    worker_connections 1024;

}

http { 

    server {

      #监听端口,若你的6699端口已经被占用,则需要修改

      listen 6699;

      location / {

          default_type text/html;

content_by_lua_block {

              ngx.say("HelloWorld")

  }

        }

    }

}

```

```

//开启nginx

sudo nginx -c ~/openresty-test/conf/nginx.conf

```

-- 浏览器中输入

-- 可以看到hello world

阅读(2653) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~