Centos7怎么安装Nginx整合Lua
导读:本文共2405.5字符,通常情况下阅读需要8分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 准备工作如果安装的linux能够联网,并且外部也能正常使用linux的端口,那么可以忽略下面两部1.设置自动获取ip(1)在linux上输入命令[root@localhost~]ipaddr#查看ip[root@localhost~]nmcliconnectionshow可以查看当前网卡信息我的是 ens33(2)修改信息[root@localhost~]vi... ...
目录
(为您整理了一些要点),点击可以直达。准备工作
如果安装的linux能够联网,并且外部也能正常使用linux的端口,那么可以忽略下面两部
1.设置自动获取ip
(1)在linux上输入命令
[root@localhost~]ipaddr#查看ip[root@localhost~]nmcliconnectionshow
可以查看当前网卡信息
我的是 ens33
(2)修改信息
[root@localhost~]vi/etc/sysconfig/network-scripts/ifcfg-ens33
将最后一行onboot=no 修改为 onboot=yes
(3)重启网络服务
[root@localhost~]#systemctlrestartnetwork
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
发现
文件默认是安装在 /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")';}
启动nginx
[root@localhostnginx-1.12.1]#./configure
在浏览器访问 虚拟对应的地址 http://xxx.xxx.xxx/hello
显示如下
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
Centos7怎么安装Nginx整合Lua的详细内容,希望对您有所帮助,信息来源于网络。