1.创建nginx工作目录
use ~/work:
mkdir ~/work
cd ~/work
mkdir logs/ conf/
2.设置PATH
PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH
3.启动
nginx -p `pwd`/ -c conf/nginx.conf
4.停止
nginx -p `pwd`/ -s stop
5.设置工程目录
配置openresty加载lua目录:nginx.conf文件的http模块下加入,如下类似的配置:
lua_package_path "/opt/openresty/lualib/?.lua;;"; #lua 模块
lua_package_cpath "/opt/openresty/lualib/?.so;;"; #c模块
6.在 nginx.conf 文件的 server {.. ...} 中的content_by_lua同级加入 lua_code_cache off; 可以方便调试lua脚本,修改lua脚本之后,不需要 reload nginx.
备注:
nginx -s reload|reopen|stop|quit #重新加载配置|重启|停止|退出 nginx
nginx -t #测试配置是否有语法错误
nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
-?,-h : 打开帮助信息
-v : 显示版本信息并退出
-V : 显示版本和配置选项信息,然后退出
-t : 检测配置文件是否有语法错误,然后退出
-q : 在检测配置文件期间屏蔽非错误信息
-s signal : 给一个 nginx 主进程发送信号:stop(停止), quit(退出), reopen(重启), reload(重新加载配置文件)
-p prefix : 设置前缀路径(默认是:/usr/local/Cellar/nginx/1.2.6/)
-c filename : 设置配置文件(默认是:/usr/local/etc/nginx/nginx.conf)
-g directives : 设置配置文件外的全局指令
nginx -p `pwd`/ -c conf/nginx.conf(-c conf/nginx.conf: 使用ngnix安装的默认路径/usr/local/openresty/nginx/路径拼接)