1、检查lua环境
注:安装这个之前保证当前系统中存在lua环境luaJit最好
luaJIT安装包:
wget -c http://luajit.org/download/LuaJIT-2.0.2.tar.gz
lua安装方法:
- 上传源码包解压到/uar/local
- cd到文件夹下LuaJIT-2.0.2目录下
- make uninstall --prefix=/usr/local/luajit
- 在/etc/profile中添加如下:
export PATH=$PATH:/usr/local/bin:/usr/bin
export LUAJIT_LIB=/usr/local/lib
2、检查需要要的相关依赖是否存在
rpm -qa pcre pcre-devel zlib zlib-devel openssl openssl-devel
成功如下:
2、检查没有问题上传安装包(一般放在/usr/local/下)
tar -zxvf openresty-1.25.3.1.tar.gz
3、装备前验证
sudo ./configure --prefix=/usr/local/openresty
验证成功如下:
4、编译安装
sudo make
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/fd9309176bb640829616942282c014ee.png#pic_center
sudo make install
5、配置环境变量
vim ~/.bash_profile 改成如下结果
source .bash_profile 使修改内容生效
6、验证是否成功
进入openresty下的nginx下,这里就是熟悉的ngxin目录了,修改nginx.conf文件
随意服务器执行:curl http://
i
p
:
{ip}:
ip:{port}/lua
Nginx.conf如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8090;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /lua {
default_type ‘text/plain’;
content_by_lua 'ngx.say("hello, lua")';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}