Nginx Notes
来源:互联网 发布:淘宝主图视频要钱吗 编辑:程序博客网 时间:2024/06/05 14:24
mac 安装 nginx + lua
安装nginx
brew install nginx
sudo chown -R kingsonwu /usr/local/lib
http://stackoverflow.com/questions/27784545/brew-error-could-not-symlink-path-is-not-writable
自己下载编译吧,否则后面要添加新模块很麻烦!
因为解压之后并没有configure 文件
解决办法是自己重新下载相应版本的nginx(curl -R -O https://nginx.org/download/nginx-1.8.0.tar.gz
),再重新编译install
下载nginx完之后之后的操作参考
http://david-je.iteye.com/blog/2057319 nginx -V
./configure [本来的参数] [要添加的modules]
make install
sudo nginx -s reload
Docroot is: /usr/local/var/wwwThe default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so thatnginx can run without sudo.nginx will load all files in /usr/local/etc/nginx/servers/.To have launchd start nginx at login: ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgentsThen to load nginx now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plistOr, if you don't want/need launchctl, you can just run: nginx
修改配置文件
sudo vim /usr/local/etc/nginx/nginx.conf
修改默认的8080端口为80给予管理员权限
sudo chown root:wheel /usr/local/opt/nginx/bin/nginx
sudo chmod u+s /usr/local/opt/nginx/bin/nginx
加入launchctl启动控制
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
运行nginx
sudo nginx
#打开 nginxnginx -s reload|reopen|stop|quit
#重新加载配置|重启|停止|退出 nginxnginx -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 : 设置配置文件外的全局指令
reference:https://segmentfault.com/a/1190000002963355
安装lua
curl -R -O http://www.lua.org/ftp/lua-5.3.3.tar.gz
tar zxf lua-5.3.3.tar.gz
cd lua-5.3.3
make macosx test
sudo make install
#这样就把Lua直接安装到/usr/local/bin下了
安装LuaJIT
http://luajit.org/download/LuaJIT-2.0.4.tar.gz make install PREFIX=/usr/local/luajit
or brew install luajit
- 注意环境变量!
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
download ngx_devel_kit
$ cd /usr/local/src
$ git clone https://github.com/simpl/ngx_devel_kit.git
download lua-nginx-module
$ cd /usr/local/src
$ git clone https://github.com/chaoslawful/lua-nginx-module.git
--add-module=/usr/local/src/ngx_devel_kit
--add-module=/usr/local/src/lua-nginx-module
referece:https://gist.github.com/jugyo/3882497
参考里面的步骤,但是不要使用brew安装nginx
当前版本编译参数:
nginx -V
在配置文件增加lua脚本
location = /lua-version { content_by_lua ' if jit then ngx.say(jit.version) else ngx.say(_VERSION) end ';}location = /test { content_by_lua ' ngx.say("Hello World") ngx.log(ngx.ERR, "err err err") ';}
➜ nginx-1.8.0 curl http://localhost/test
Hello World
➜ nginx-1.8.0 curl http://localhost/lua-version
LuaJIT 2.0.4
其他
Nginx开发从入门到精通:http://tengine.taobao.org/book/
Nginx配置文件nginx.conf中文详解:http://www.ha97.com/5194.html
Ngx_Lua使用分享:http://17173ops.com/2013/11/01/17173-ngx-lua-manual.shtml
Nginx+Lua开发入门:http://jinnianshilongnian.iteye.com/blog/2186448
- Nginx Notes
- Nginx 安装说明(Nginx Installation Notes)¶
- Notes
- notes
- Notes
- notes
- notes
- notes
- notes
- Notes
- notes
- Notes
- notes
- Notes
- notes
- Notes
- Notes
- Notes
- 1038. 统计同成绩学生(20)
- JS判断当前手机类型
- Linux tcpdump命令详解
- 促销中“满X优惠”问题的两种解法:动态规划和枚举法
- 分布式服务框架Dubbo使用小结
- Nginx Notes
- logstash 使用grok正则解析日志
- 122.[LeetCode]Best Time ti Buy and Shell stock II
- 高效Web开发的10个jQuery代码片段
- 如何SSDT执行报表服务(1):登陆报表服务器
- GEEK编程练习— —2的次方数
- 构造函数的理解
- Linux启动流程分析(CentOS 5.x)
- 好题集锦