Nginx详解二十三:Nginx深度学习篇之Nginx+Lua开发环境搭建
Nginx+Lua开发环境
1、下载LuaJIT解释器
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar -zxvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make install PREFIX=/usr/local/LuaJIT
/etc/profile 文件中加入环境变量
export LUAJIT_LIB=/usr/local/LuaJIT/lib
export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0
2、下载ngx_devel_kit和lua-nginx-module
cd /opt/download
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
分别解压,不需要安装
3、重新编译nginx
cd /opt/download
wget http://nginx.org/download/nginx-1.12.1.tar.gz
执行解压
cd到nginx目录下按照如下方式编译:
# 最后两个add是之前解压的ngx_devel_kit和lua-nginx-module
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/opt/download/ngx_devel_kit-0.3.0 --add-module=/opt/download/lua-nginx-module-0.10.9rc7
如果编译的时候报以下错误
执行:yum -y install openssl openssl-devel成功之后再编译(这里提示缺什么就yum -y install)
再次执行编译命令编译成功
make一下 :make -j 4 && make install,会覆盖之前yum下载的nginx
4、加载lua库,加入到ld.so.conf文件
执行命令:echo "/usr/local/LuaJIT/lib" >> /etc/ld.so.conf
然后执行:ldconfig
验证:
执行nginx -V查看参数
测试Lua
cd /etc/nginx/conf.d/default.conf 加入下面的location
location /hello_lua {
default_type 'text/plain';
content_by_lua 'ngx.say("hello, lua")';
}
重启nginx:
nginx -tc /etc/nginx/nginx.conf 检查错误
nginx -s reload -c /etc/nginx/nginx.conf 重新加载
执行reload的时候报错:nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
解决办法:nginx.conf文件的路径可以从nginx -t的返回中找到
先执行:nginx -c /etc/nginx/nginx.conf
再执行:nginx -s reload
访问192.168.1.141/hello_lua会出现”hello, lua”表示安装成功
Nginx调用Lua模块指令
Nginx的可插拔模块化加载执行,共11个处理阶段
Nginx Lua API
这里列出一些常用的API,更多的API可以官网查看
Nginx详解二十三:Nginx深度学习篇之Nginx+Lua开发环境搭建的更多相关文章
- 【深度学习笔记】Anaconda及开发环境搭建
在学习了一段时间台大李宏毅关于deep learning的课程,以及一些其他机器学习的书之后,终于打算开始动手进行一些实践了. 感觉保完研之后散养状态下,学习效率太低了,于是便想白天学习,晚上对白天学 ...
- nginx 与 lua 开发环境搭建
首先下载最新版的 相关软件 的安装文件. nginx: http://nginx.org/en/download.html LuaJIT: http://luajit.org/download.htm ...
- 区块链Hyperledger Fabric 学习记录(一)开发环境搭建(ubuntu16.04/ubuntu18.04)
目录 Fabric开发环境搭建 更新说明 教程环境及软件版本 Docker 安装Docker 配置用户组 配置Aliyun Docker加速器 安装docker-compose Go 下载源码 安装源 ...
- Android学习笔记(一)开发环境搭建
Android开发环境搭建 安装JDK 1.如果你还没有JDK的话,可以去这里http://www.oracle.com/technetwork/java/index.html ,接下来的工作就是安装 ...
- 学习《深度学习与计算机视觉算法原理框架应用》《大数据架构详解从数据获取到深度学习》PDF代码
<深度学习与计算机视觉 算法原理.框架应用>全书共13章,分为2篇,第1篇基础知识,第2篇实例精讲.用通俗易懂的文字表达公式背后的原理,实例部分提供了一些工具,很实用. <大数据架构 ...
- angularjs2 学习笔记(一) 开发环境搭建
开发环境,vs2013 update 5,win7 x64,目前最新angular2版本为beta 17 第一步:安装node.js 安装node.js(https://nodejs.org/en/) ...
- hibernate学习系列-----(1)开发环境搭建
其实一两个月前就在了解hibernate方面的知识了,但一直以来,都没有好好的总结,而且一直使用的是myeclipse,感觉有些傻瓜式的操作就可以搭建起hibernate的开发环境,但这样一点都不好, ...
- Nginx详解二十:Nginx深度学习篇之HTTPS的原理和作用、配置及优化
一.HTTPS原理和作用: 1.为什么需要HTTPS?原因:HTTP不安全1.传输数据被中间人盗用.信息泄露2.数据内容劫持.篡改 2.HTTPS协议的实现对传输内容进行加密以及身份验证 对称加密:加 ...
- Nginx详解二十四:Nginx深度学习篇之灰度发布
实战场景 - 灰度发布 灰度发布的作用:按照一定的关系区别,分部分的代码进行上线,使代码的发布能平滑过渡上线实现方式: 1.用户的信息cookie等信息区别 2.根据用户的IP地址 安装memcach ...
随机推荐
- Django REST framework 第五章 Relationships & Hyperlinked APIs
到目前为止,API内部的关系是使用主键来代表的.在这篇教程中,我们将提高API的凝聚力和可发现性,通过在相互关系上使用超链接. Creating an endpoint for the root of ...
- Python 16 html 基础 jQuery & Javascript研究
基础内容 DOM操作 javascript探讨 JQuery初识 DOM innerText ==>获取仅文本 innerHtml ==>获取全部内容 <div id=" ...
- RocketMQ RPC
(1)NameServer:在MQ集群中做的是做命名服务,更新和路由发现 broker服务: (2)Broker-Master:broker 消息主机服务器: (3)Broker-Slave:brok ...
- Flask里面session的基本操作
#session是依赖于flask的session模块 #如果想使用session模块,在配置里必须定义sessionkey from flask import Flask,session #建立对象 ...
- Solr 7.7.0 部署到Tomcat
第一步 1.Solr 解压后server/solr-webapp下一个webapp目录,它就是Solr的Web项目,把它复制到tomcat的webapps目录下并改名为solr # 进入Solr的se ...
- python初级实战-----关于邮件发送问题
python发邮件需要掌握两个模块的用法,smtplib和email,这俩模块是python自带的,只需import即可使用.smtplib模块主要负责发送邮件,email模块主要负责构造邮件. sm ...
- 框架中的导航框架 & position定位
框架中,通过链接将一个页面显示在另一个框架中: 总框架: <frameset cols="15%,*"> <frame src="xx.html ...
- pt-table-sync 使用方法【转】
28. pt-table-sync28.1 pt-table-sync 作用 使用对两个库不一致的数据进行同步,他能够自动发现两个实例间不一致的数据,然后进行sync操作,pt-table-sync无 ...
- MySQL用source命令导入不记入binlog中【原创】
试验环境,MySQL主主复制 主库10.72.16.112 从库10.72.16.50 一直有个疑问,利用sql_log_bin=0可以临时在客户端停止将操作记入binlog中,如果使用source命 ...
- python下载mp4 同步和异步下载支持断点续下
Range 用于请求头中,指定第一个字节的位置和最后一个字节的位置,一般格式: Range:(unit=first byte pos)-[last byte pos] Range 头部的格式有以下几种 ...