centos7搭建lua开发环境

下载源码包:curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz

解压:tar zxf lua-5.3.4.tar.gz

进入目录:cd lua-5.3.4

编译:make linux test

最后:make install

 

安装过程报错: 错误:readline/readline.h:没有那个文件或目录解决方法

原因:确实相关依赖包

解决方法:yum install libtermcap-devel ncurses-devel libevent-devel readline-devel

验证:

输入:lua

Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio
> print(“hello world!”)

openRestry 入门

安装

操作系统:centos7

安装依赖:yum install readline-devel pcre-devel openssl-devel gcc perl

yum install  postgresql-devel

下载:wget https://openresty.org/download/openresty-1.11.2.3.tar.gz

解压: tar -zxvf openresty-1.11.2.3.tar.gz

安装:cd openresty-1.11.2.3

 

./configure --prefix=/usr/local/openresty \
            --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_postgres_module

设置环境变量:

将 nginx 目录添加到 PATH 中。打开文件 /etc/profile, 在文件末尾加入

            export PATH=$PATH:/opt/openresty/nginx/sbin
需要重新加载环境变量才会生效,可通过命令source /etc/profile 或重启服务器
hello world:
创建工作目录
mkdir ~/work
cd ~/work
mkdir logs/ conf/

创建配置文件
cd ~/work/conf/
vim nginx.conf

文件内容:
worker_processes 1;
error_log logs/error.log;
events{
 worker_connections 1024;
}
http {
 server {
 listen 80;
 location / {
 default_type text/html;
 content_by_lua_block {
 ngx.say("Hello world!");
 }
 }
 }
}


启动nginx: nginx -p ~/work/

访问页面:curl http://localhost:80 -i
返回:
HTTP/1.1 200 OK
Server: openresty/1.11.2.3
Date: Wed, 26 Apr 2017 07:53:42 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive

Hello world!





done!