Centos7怎么安装Nginx整合Lua(centos7,lua,nginx,编程语言)

时间:2024-05-06 00:52:32 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

准备工作

如果安装的linux能够联网,并且外部也能正常使用linux的端口,那么可以忽略下面两部

1.设置自动获取ip

(1)在linux上输入命令

[root@localhost~]ipaddr#查看ip[root@localhost~]nmcliconnectionshow

可以查看当前网卡信息

Centos7怎么安装Nginx整合Lua

我的是 ens33

(2)修改信息

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

将最后一行onboot=no 修改为 onboot=yes

(3)重启网络服务

[root@localhost~]#systemctlrestartnetwork

Centos7怎么安装Nginx整合Lua

2.关闭防火墙

systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动

3.准备安装是发现没有wget命令,可以先按照线面安装如果下面提示没有wget命令时,可以执行这一步

[root@localhost~]#yum-yinstallwget

安装

1.安装依赖环境

[root@localhost~]#yum-yinstallgcczlibzlib-develpcre-developensslopenssl-devel

2.安装luajit

我是在/usr/local路径下创建了 luajit 文件夹

[root@localhostluajit]#wgethttp://luajit.org/download/luajit-2.0.2.tar.gz[root@localhostluajit]#tar–xvfluajit-2.0.2.tar.gz[root@localhostluajit]#cdluajit-2.0.2[root@localhostluajit-2.0.2]#makeinstall

3.安装nginx

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

我是在/usr/local路径下创建了 nginx 文件夹

[root@localhostnginx]#wgethttps://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz[root@localhostnginx]#wgethttps://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz[root@localhostnginx]#wgethttp://nginx.org/download/nginx-1.12.1.tar.gz#注意下载后的压缩包没有文件名称,但是根据版本号能区分是哪个文件[root@localhostnginx]#tar-xvfv0.3.0.tar.gz[root@localhostnginx]#tar-xvfv0.10.9rc7.tar.gz[root@localhostnginx]#tar-xvfnginx-1.12.1.tar.gz

(2)编译nginx

[root@localhostnginx]#cdnginx-1.12.1[root@localhostnginx-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@localhostnginx-1.12.1]#make[root@localhostnginx-1.12.1]#makeinstall

(4)启动nginx

启动时会nginx可能会报错

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

找不到libluajit-5.1.so.2这个文件

解决办法

1.找到 libluajit-5.1.so.2,libluajit-5.1.so.2.0.2这两个文件复制到 对应的lib下

64位是 /usr/lib64

32位是 /usr/lib

[root@localhostnginx-1.12.1]#find/-namelibluajit-5.1.so.2

发现

Centos7怎么安装Nginx整合Lua

文件默认是安装在 /usr/local/lib/libluajit-5.1.so.2下

[root@localhostnginx-1.12.1]#cp/usr/local/lib/libluajit-5.1.so.2/usr/lib64/[root@localhostnginx-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")';}

Centos7怎么安装Nginx整合Lua

启动nginx

[root@localhostnginx-1.12.1]#./configure

在浏览器访问 虚拟对应的地址 http://xxx.xxx.xxx/hello

显示如下

Centos7怎么安装Nginx整合Lua

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Centos7怎么安装Nginx整合Lua的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:CentOS7如何安装Nginx并配置自动启动下一篇:

3 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18