環境:Mac、Brew安裝
brew安裝很方便,安裝完成後可以直接運行nginx的。
安裝nginx
brew install nginx-full - -with-lua-module
後面的module選項可以通過如下命令查看:
brew options nginx-full
--with-accept-language-module Compile with support for Accept Language module--with-accesskey-module Compile with support for HTTP Access Key module--with-addition Compile with support for HTTP Addition module--with-lua-module Compile with support for LUA module ....
如果安裝錯誤或者想嘗試下別的,可以卸載重裝
brew uninstall nginx-full
(中途若需要安裝其它依賴,都可以通過brew安裝。因為鼓搗了好久,不確定是不是還需要安裝別的)
使用lua
建立lua.conf檔案,放到/usr/local/etc/nginx/conf下,conf是建立的檔案夾
#lua.conflua_package_path '/usr/local/Cellar/lua51/5.1.5_4/lib/?.lua;;'; #lua 模組lua_package_cpath '/usr/local/Cellar/lua51/5.1.5_4/lib/?.so;;'; #c模組server { listen 8083; server_name localhost; location /lua{ default_type 'text/html'; content_by_lua 'ngx.say("hello world")'; }}
若沒有lua51,通過brew安裝就好
brew install lua51
引入
在nginx.config檔案的http模組下引入檔案(可以自己指定位置)
include conf/*.conf;
測試
nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
localhost:8083/lua –>hello world
有問題歡迎留言
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了nginx-Brew安裝lua模組,包括了nginx,brew方面的內容,希望對PHP教程有興趣的朋友有所協助。