欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Centos7 安裝Nginx整合Lua的示例代碼

 更新時(shí)間:2018年12月25日 14:17:43   作者:BAKERSTREETw  
這篇文章主要介紹了Centos7 安裝Nginx整合Lua的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

前言

本人的使用的電腦是Mac,操作系統(tǒng)是macOS Mojave。電腦上裝有虛擬機(jī)。

虛擬機(jī)上安裝Centos7操作系統(tǒng),在其之上安裝Nginx及Luau類庫(kù),整個(gè)過(guò)程是在系統(tǒng)安裝完成之后開(kāi)始記錄。

建議安裝前先拍快照,出現(xiàn)問(wèn)題可以恢復(fù)

準(zhǔn)備工作

如果安裝的Linux能夠聯(lián)網(wǎng),并且外部也能正常使用Linux的端口,那么可以忽略下面兩部

1.設(shè)置自動(dòng)獲取ip

(1)在Linux上輸入命令

[root@localhost ~]ip addr  #查看ip
[root@localhost ~]nmcli connection show

可以查看當(dāng)前網(wǎng)卡信息


我的是 ens33

(2)修改信息

[root@localhost ~]vi /etc/sysconfig/network-scripts/ifcfg-ens33

將最后一行ONBOOT=no 修改為 ONBOOT=yes

(3)重啟網(wǎng)絡(luò)服務(wù)

[root@localhost ~]# systemctl restart network

2.關(guān)閉防火墻

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開(kāi)機(jī)啟動(dòng)

3.準(zhǔn)備安裝是發(fā)現(xiàn)沒(méi)有wget命令,可以先按照線面安裝如果下面提示沒(méi)有wget命令時(shí),可以執(zhí)行這一步

[root@localhost ~]#yum -y install wget

安裝

1.安裝依賴環(huán)境

[root@localhost ~]#yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

2.安裝LuaJIT

我是在/usr/local路徑下創(chuàng)建了 LuaJIT 文件夾

[root@localhost LuaJIT]#wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
[root@localhost LuaJIT]#tar –xvf LuaJIT-2.0.2.tar.gz
[root@localhost LuaJIT]#cd LuaJIT-2.0.2
[root@localhost LuaJIT-2.0.2]#make install

3.安裝nginx

(1)下載ngx_devel_kit、lua-nginx-module、nginx

我是在/usr/local路徑下創(chuàng)建了 nginx 文件夾

[root@localhost nginx]#wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
[root@localhost nginx]#wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
[root@localhost nginx]#wget http://nginx.org/download/nginx-1.12.1.tar.gz 
#注意下載后的壓縮包沒(méi)有文件名稱,但是根據(jù)版本號(hào)能區(qū)分是哪個(gè)文件
[root@localhost nginx]#tar -xvf v0.3.0.tar.gz
[root@localhost nginx]#tar -xvf v0.10.9rc7.tar.gz
[root@localhost nginx]#tar -xvf nginx-1.12.1.tar.gz

(2)編譯Nginx

[root@localhost nginx]# cd nginx-1.12.1
[root@localhost nginx-1.12.1]#./configure --prefix=/usr/local/nginx --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.9rc7

(3)安裝

[root@localhost nginx-1.12.1]#make
[root@localhost nginx-1.12.1]#make install

(4)啟動(dòng)nginx

啟動(dòng)時(shí)會(huì)nginx可能會(huì)報(bào)錯(cuò)

./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: N

找不到libluajit-5.1.so.2這個(gè)文件

解決辦法

1.找到 libluajit-5.1.so.2,libluajit-5.1.so.2.0.2這兩個(gè)文件復(fù)制到 對(duì)應(yīng)的lib下

64位是 /usr/lib64

32位是 /usr/lib

[root@localhost nginx-1.12.1]#find / -name libluajit-5.1.so.2

發(fā)現(xiàn)


文件默認(rèn)是安裝在 /usr/local/lib/libluajit-5.1.so.2下

[root@localhost nginx-1.12.1]#cp /usr/local/lib/libluajit-5.1.so.2 /usr/lib64/
[root@localhost nginx-1.12.1]#cp /usr/local/lib/libluajit-5.1.so.2.0.2 /usr/lib64

在nginx安裝目錄下,修改nginx.conf文件

在Server代碼塊下添加如下代碼

location /hello{
    default_type 'text/plain';
    content_by_lua 'ngx.say("hello,lua")';
  }

啟動(dòng)nginx

[root@localhost nginx-1.12.1]#./configure

在瀏覽器訪問(wèn) 虛擬對(duì)應(yīng)的地址 http://xxx.xxx.xxx/hello

顯示如下


到此就成功了

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論