嵌入式kepler/xavante安装

简单方法安装

一、发现一个非常简单且实用安装方法:

1:安装git
    yum install git
2:lua安装请参考原来方法(见下面)
3:下载luarocks:  http://luarocks.org/releases/
4: 进入luarocks目录
   ./configure --prefix=/home/alex/work/kepler/build
   make
   make install
5: 编译安装: wsapi-xavante, cgilua, md5,copas,rings
   cd /home/alex/work/kepler/build
   ./bin/luarocks install wsapi-xavante CC=arm-linux-uclibc-gcc LD=arm-linux-uclibc-ld
   ./bin/luarocks install cgilua CC=arm-linux-uclibc-gcc LD=arm-linux-uclibc-ld
   ./bin/luarocks install md5 CC=arm-linux-uclibc-gcc LD=arm-linux-uclibc-ld
   ./bin/luarocks install copas CC=arm-linux-uclibc-gcc LD=arm-linux-uclibc-ld
   ./bin/luarocks install rings CC=arm-linux-uclibc-gcc LD=arm-linux-uclibc-ld 

  ./bin/luarocks install luasql-sqlite3 CC=powerpc-fsl-linux-gnuspe-gcc LD=powerpc-fsl-linux-gnuspe-ld SQLITE_LIBDIR=/workspace/ptzsp/other_vendor/ppcp_lib/lib

(如果出现连接错误,请将LD修改为相应的gcc)
6: luaexpat安装请参考原来方法(见下面)

7:将/home/alex/work/kepler/build/bin目录下的所有文件(cgilau.cgi,wsapi等),将里面的 /home/alex/work/kepler/build替换成自己需要的路径即可

瘦身

cd /home/alex/work/tmp/kepler/build
rm -rf etc
arm-linux-strip bin/*
arm-linux-strip lib/*
arm-linux-strip lib/lua/5.1/*
arm-linux-strip lib/lua/5.1/md5/*
arm-linux-strip lib/lua/5.1/mime/*
arm-linux-strip lib/lua/5.1/socket/*

删除lib/lua/luarocks目录下的除bin目录外的其他目录

 

运行

wsapi --cgilua --config=config.lua   webfilesfolder

 

FAQ:

如果出现:

/usr/local/lib/lua/5.1//lfs.so: cannot restore segment prot after reloc: Permission denied

请关闭selinux

setenforce 0

-------------------------------------------------------------------------------

分割线:下面为老的安装方法

-------------------------------------------------------------------------------

编译

1: install lua(需要用到改写的Makefile)

   1) 修改 src/Makefile
     CC=$(CROSS_COMPILE)gcc
     AR=$(CROSS_COMPILE)ar
     RANLIB=$(CROSS_COMPILE)ranlib
     删除-lreadline -lhistory -lncurses
   2)src/luaconf.h
     注释掉line 39 (disable LUA_USE_READLINE)
   3) make linux CROSS_COMPILE=arm-linux-
   4) make install INSTALL_TOP=/home/alex/work/kepler/build


2: xavante-2.0.1

   make install PREFIX=/home/alex/work/kepler/build

3: luasocket-2.0.2

   1).修改config
     a.替换gcc为$(CROSS_COMPILE)gcc
     b.放开LUA_INC,并将LUA_INC修改为LUAINC=-I/usr/local/include
     c. 在文档前面定义 PREFIX=/usr/local
     d.将所有/usr/local替换为$(PREFIX)
   2) make CROSS_COMPILE=arm-linux- PREFIX=/home/alex/work/kepler/build
   3) make install PREFIX=/home/alex/work/kepler/build

4: copas-1.1.4

   make install PREFIX=/home/alex/work/kepler/build

5: luafilesystem-1.4.2

   1) config
     CC=$(CROSS_COMPILE)gcc
   2) make CROSS_COMPILE=arm-linux- PREFIX=/home/alex/work/kepler/build
   3) make install PREFIX=/home/alex/work/kepler/build

6: coxpcall-1.13.0

   make install PREFIX=/home/alex/work/kepler/build/kepler/ BIN_DIR=/home/alex/work/kepler/build/bin/ LUA_DIR=/home/alex/work/kepler/build/share/lua/5.1  

7: rings-1.2.2

   1) config
     CC=$(CROSS_COMPILE)gcc
   2) make CROSS_COMPILE=arm-linux-
   3) make install PREFIX=/home/alex/work/kepler/build

8: md5-1.1.2

   1) config
     CC=$(CROSS_COMPILE)gcc
   2) make CROSS_COMPILE=arm-linux-
   3) make install PREFIX=/home/alex/work/kepler/build

9: cgilua-5.1.3

1) make install 

 

10: expat-2.0.1

如果需要xml解析,才需要安装该模块

1) ./configure --host=arm-linux --prefix=/home/alex/work/kepler/build
2) make
3) make install

11:   luaexpat-1.1

xml解析需要安装该模块

1) config   
    PREFIX = /home/alex/work/tmp/kepler/build
    LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
    LUA_DIR= $(PREFIX)/share/lua/5.1
    LUA_INC= $(PREFIX)/include
    EXPAT_INC= $(PREFIX)/include/
    EXPAT_LIB= $(PREFIX)/lib
    LIB_OPTION= -shared #for Linux
    LUA_VERSION_NUM= 501
    CC=$(CROSS_COMPILE)gcc
2) make CROSS_COMPILE=arm-linux-   
3) make install

瘦身

cd /home/alex/work/tmp/kepler/build
arm-linux-strip bin/*
arm-linux-strip lib/*
arm-linux-strip lib/lua/5.1/*
arm-linux-strip lib/lua/5.1/md5/*
arm-linux-strip lib/lua/5.1/mime/*
arm-linux-strip lib/lua/5.1/socket/*

 

配置

keper_init.lua

在/home/alex/work/kepler/build/share/lua/5.1目录下新建文件 : kepler_init.lua, 内容如下,具体目录请根据自己实际需求修改:

--
-- Kepler bootstrap file
-- Defines the default directories for Kepler
--

-- Kepler applications directory
KEPLER_APPS = [[/usr/local/kepler/apps]]

-- Kepler configuration directory
KEPLER_CONF = [[/usr/local/kepler/etc]]

-- Kepler logs directory
KEPLER_LOG = [[/usr/local/kepler/log]]

-- Kepler temporary directory
KEPLER_TMP = [[/tmp]]

-- Kepler default web directory
KEPLER_WEB  = [[/usr/local/www]]

-- CGILua globals (usually defined using KEPLER globals)
CGILUA_APPS = KEPLER_APPS.."/cgilua"
CGILUA_CONF = KEPLER_CONF.."/cgilua"
CGILUA_TMP = KEPLER_TMP
CGILUA_ISDIRECT = true

RINGS_CGILUA_GLOBALS = {
    "KEPLER_APPS", "KEPLER_CONF", "KEPLER_LIB",
    "KEPLER_LOG", "KEPLER_LUA", "KEPLER_TMP", "KEPLER_WEB",
    "CGILUA_APPS", "CGILUA_CONF", "CGILUA_TMP", "CGILUA_ISDIRECT",
}

config.lua

mkdir /home/alex/work/build/kepler/etc/xavante

mkdir /home/alex/work/build/kepler/etc/cgilua

cp kepler-1.1.1/conf/xavante/config.lua /home/alex/work/build/kepler/etc/xavante/
cp kepler-1.1.1/conf/cgilua/config.lua /home/alex/work/build/kepler/etc/cgilua/

log目录

mkdir /home/alex/work/build/kepler/log

 

配置端口号

修改如下

vi /home/alex/work/build/kepler/etc/xavante/config.lua

xavante.HTTP{
    server = {host = "*", port = 80},

    defaultHost = {
        rules = simplerules
    },
}

 

start文件

cp kepler-1.1.1/src/xavante_start /home/alex/work/build/bin

该文件内容为:

#!/usr/bin/env lua

-------------------------------------------------------------------------------
-- Starts the Xavante Web server.
--
-- See xavante/config.lua and the online documentation for configuration details.
--
-- Authors: Javier Guerra and Andre Carregal
-- Copyright (c) 2004-2007 Kepler Project
--
-- $Id: xavante_start,v 1.3 2008/07/03 20:25:47 carregal Exp $
-------------------------------------------------------------------------------

require "kepler_init"

XAVANTE_CFG = KEPLER_CONF.."/xavante/config.lua"
XAVANTE_LOG = KEPLER_LOG.."/xavante.log"
XAVANTE_TMP = KEPLER_TMP
XAVANTE_WEB = KEPLER_WEB

local tostring = tostring

local log = io.open(XAVANTE_LOG, "a+")

if not log then
        error("Could not open log file. Please check the write permissions for:"..XAVANTE_LOG)
end

io.stdout = log
io.stderr = log
print = function (...)
  local nargs = select('#', ...)
  for i = 1, nargs-1 do
    log:write(tostring((select(i, ...))))
    log:write("/t")
  end
  log:write(tostring(select(nargs, ...)))
  log:write("/n")
end

XAVANTE_ISFINISHED = XAVANTE_ISFINISHED or function() return false end

local res, err = pcall(require, "xavante")

if not res then
    io.stderr:write(err .. "/n")
else
    ---------------------------------------------------------------------------
    -- Loads the configuration file and starts Xavante
    --
    -- XAVANTE_ISFINISHED and XAVANTE_TIMEOUT are optional globals that can
    -- control how Xavante will behave when being externally controlled.
    -- XAVANTE_ISFINISHED is a function to be called on every step of Xavante,
    -- XAVANTE_TIMEOUT is the timeout to be used by Copas.
    ---------------------------------------------------------------------------
    io.stdout:write("[Xavante launcher] Starting Xavante.../n")

    -- tries to load the user configuration
    res, err = loadfile(XAVANTE_CFG)
    if res then
        res()
    else
        error("Error loading user config.lua" .. err)
    end

    res, err = pcall(xavante.start, function (...)
          log:flush()
          return XAVANTE_ISFINISHED(...)
    end, XAVANTE_TIMEOUT)
    if not res then
        io.stderr:write(err .. "/n")
    else
        io.stderr:write("[Xavante launcher] Xavante stopped/n")
    end
end

log:close()

你可能感兴趣的:(function,gcc,嵌入式,lua,permissions)