分类: 系统运维
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