国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

nginx與lua開發環境搭建

2024-06-28 14:31:46
字體:
來源:轉載
供稿:網友

首先下載最新版的 相關軟件 的安裝文件。

nginx: http://nginx.org/en/download.html

LuaJIT: http://luajit.org/download.html

lua-nginx-module: https://github.com/openresty/lua-nginx-module/releases/tag/v0.9.16

ngx_devel_kit: https://github.com/simpl/ngx_devel_kit/releases/tag/v0.2.19

[root@localhost src]# ll -ttotal 22408-rw-r--r--.  1 root root    65029 Sep 13 09:00 ngx_devel_kit-0.2.19.tar.gz-rw-r--r--.  1 root root   523900 Sep 13 09:00 lua-nginx-module-0.9.16.tar.gz-rw-r--r--.  1 root root   847615 Sep 13 09:00 LuaJIT-2.0.4.tar.gz-rw-r--r--.  1 root root   832104 Sep  8 13:23 nginx-1.8.0.tar.gz

1. 先解壓安裝 LuaJIT

tar zxvf LuaJIT-2.0.4.tar.gz

cd LuaJIT-2.0.4 進去

make && make install

搞定。

然后分別解壓 ngx_devel_kit-0.2.19.tar.gz 和 lua-nginx-module-0.9.16.tar.gz

2. 再解壓安裝 nginx ,加入 ngx_devel_kit 和 lua-nginx-module 模塊:

[root@localhost nginx]# ./configure --add-module=/usr/local/src/lua-nginx-module-0.9.16 /> --add-module=/usr/local/src/ngx_devel_kit-0.2.19

[root@localhost nginx]# make && make install

安裝完成,測試一般會報錯:

[root@localhost sbin]# ./nginx./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

解決方法:

[root@localhost lib]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf[root@localhost lib]# cat /etc/ld.so.conf.d/usr_local_lib.conf/usr/local/lib[root@localhost lib]# ldconfig

在測試,OK。

[root@localhost sbin]# ./nginx[root@localhost sbin]# ps -elf|grep nginx1 S root      8758     1  0  80   0 -  1612 -      09:26 ?        00:00:00 nginx: master PRocess ./nginx5 S nobody    8759  8758  0  80   0 -  1662 -      09:26 ?        00:00:00 nginx: worker process5 S nobody    8760  8758  0  80   0 -  1662 -      09:26 ?        00:00:00 nginx: worker process0 S root      8762  1723  0  80   0 -  1088 -      09:26 pts/1    00:00:00 grep ngin

配置了 ndk 和 lua-nginx-module 的nginx 要別原來大一些

[root@localhost sbin]# ls -lhtotal 7.1M-rwxr-xr-x. 1 root root 4.4M Sep 13 09:20 nginx-rwxr-xr-x. 1 root root 2.8M Sep  9 10:50 nginx.old

3. 測試Lua 模塊配置是否成功:

在 nginx.conf 文件中加入:

        location /lua {                set $test "hello, world.";                content_by_lua '                        ngx.header.content_type = "text/plain";                        ngx.say(ngx.var.test);                ';        }

然后 nginx -t; 測試無錯誤,然后 nginx -s reload; 重新加載nginx.conf文件

然后訪問 192.168.1.200/lua

看到結果,表示 nginx, Lua 開發環境搭建成功。

上面配置的意思,就是定義一個變量 $test, 然后以 text/pain 格式輸出它的值。$test定義變量,讓人想起 php 和 shell 變量的定義。

 

其實,nginx 和 lua 有專門的已經配置好了的開發環境: OpenResty 和 Tengine

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹿泉市| 霞浦县| 邵阳县| 团风县| 清徐县| 林芝县| 马边| 盘锦市| 桃园市| 西贡区| 沅陵县| 北川| 静海县| 尤溪县| 白朗县| 潜山县| 安化县| 阳东县| 山西省| 临漳县| 昌都县| 宁阳县| 湘西| 平邑县| 万山特区| 福建省| 锦屏县| 沙雅县| 崇文区| 金溪县| 合水县| 大港区| 福州市| 舟山市| 闸北区| 广河县| 鄂伦春自治旗| 陆川县| 同心县| 邯郸县| 塔城市|