orange的安装

一、 安装lor

 # git clone https://github.com/sumory/lor.git
 # cd lor
 # make install

二、 导入orange的数据库
orange项目install文件下有orange的数据库sql文件,选择最新版本导入到本地mysql

  git clone https://github.com/sumory/orange.git
  导入数据库
  create databases orange;
  use orange;
  source /home/myopenresty/orange/install/orange-v0.7.0.sql;

三、 安装第三方依赖
1 luarocks安装luafilesystem和luasocket

  yum install luarocks
  luarocks install luafilesystem
  luarocks install luasocket

执行luarocks list展示如下信息,则是已经安装成功:

luafilesystem
   1.7.0-2 (installed) - /usr/local/luarocks/lib/luarocks/rocks

luarocks
   2.2.2-1 (installed) - /usr/local/luarocks/lib/luarocks/rocks

2 opm安装其他的包

  cd orange
  make install 
  opm --install-dir=./ get zhangbao0325/orangelib

安装完成之后,orange目录下会出现lualib文件夹,里面是orange所依赖的所有第三方包

四、 修改配置文件

  cd conf
  cp orange.example.conf orange.conf
  cp nginx.example.conf nginx.conf

修改orange.conf里配置,将数据库的配置改成自己的mysql信息。
修改nginx.conf里的lua_package_path,将luarocks安装的lua文件路径

luarocks list

Warning: Failed loading manifest for /root/.luarocks/lib/luarocks/rocks: /root/.luarocks/lib/luarocks/rocks/manifest: No such file or directory

可能遇到的问题

1 执行opm时可能遇到的报错:

  Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/openresty/bin/opm line 16.
  BEGIN failed--compilation aborted at /home/openresty/bin/opm line 16.

	解决方法:	
	yum -y install perl perl-devel
	yum -y install perl-Digest-MD5

2 执行luarocks可能遇到的报错:

# /usr/bin/luarocks install luafilesystem
Installing https://luarocks.org/luafilesystem-1.7.0-2.src.rock...
Using https://luarocks.org/luafilesystem-1.7.0-2.src.rock... switching to 'build' mode
gcc -O2 -fPIC -I/usr/include -c src/lfs.c -o src/lfs.o
src/lfs.c:66:17: fatal error: lua.h: No such file or directory
#include 
               ^
compilation terminated.

Error: Build error: Failed compiling object src/lfs.o
这是因为luarocks找不到lua.h文件

解决方法:
rpm -e luarocks --nodeps
源码安装luarocks,安装的时候通过--with-lua-include指定对应的lua.h所在的目录
先找到lua.h的位置:
find / -name "lua.h"
/usr/local/src/openresty-1.13.6.2/bundle/LuaJIT-2.1-20180420/src/lua.h
/usr/local/src/openresty-1.13.6.2/build/LuaJIT-2.1-20180420/src/lua.h
/usr/local/src/openresty-1.13.6.2/build/luajit-root/home/openresty/luajit/include/luajit-2.1/lua.h
/home/openresty/luajit/include/luajit-2.1/lua.h

安装的时候指定--with-lua-include路径:
./configure --prefix=/usr/local/luarocks --with-lua-include=/home/openresty/luajit/include/luajit-2.1

make && make install

3 启动sh start.sh时报错:

sh /home/myopenresty/orange/start.sh 
start orange..
nginx: [error] init_by_lua error: ./lualib/resty/pl/path.lua:28: pl.path requires LuaFileSystem
stack traceback:
        [C]: in function 'error'
        ./lualib/resty/pl/path.lua:28: in main chunk
        [C]: in function 'require'
        ./lualib/resty/dns/client.lua:24: in main chunk
        [C]: in function 'require'
        ./orange/orange.lua:11: in main chunk
        [C]: in function 'require'
        init_by_lua:2: in main chunk
这是由于lfs.so动态库不再lua默认搜索库的路径中

解决方法:
先找到lfs.so的文件位置:
#  find / -name "lfs.so"
/usr/local/luarocks/lib/lua/5.1/lfs.so

修改nginx.conf文件,在lua_package_path下一行加入指令:
lua_package_cpath '/usr/local/luarocks/lib/lua/5.1/?.so;;';

你可能感兴趣的:(Lua)