Fail to load lua module

615 views
Skip to first unread message

Anto

unread,
Feb 23, 2016, 5:38:51 AM2/23/16
to openresty-en
Hi,

First of all, congratulate him on his work with modules of open source.

I have followed post on how to create an image server (http://leafo.net/posts/creating_an_image_server.html), for my small blogs and I have obtained a series of failures, that I have been resolving but I have come to a point that I know how to fix it. I have never developed in Lua or know the environment variables to develop nginx lua modules.

I'm using module (https://github.com/leafo/magick) and indications of the post (http://leafo.net/posts/creating_an_image_server.html), but not with that work, if I tried to modify the LUA file to pass parameters (path, size,...) way static in the file, and run from console with luajit, works correctly, but from nginx, I get error 500.

Install by luarocks.

My system:

### Luarocks

root@nineleven:~ # luarocks-5.1 list

Installed rocks:
----------------

magick
   1.1.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1
   
root@nineleven:~ # ls -l /usr/local/share/lua/5.1/
total 8
drwxr-xr-x  7 root  root  1024 Feb 16 17:39 luarocks
drwxr-xr-x  2 root  root   512 Feb 17 02:14 magick

root@nineleven:~ # ls -l /usr/local/share/lua/5.1/magick/
total 20
-rw-r--r--  1 root  root  17491 Feb 17 02:14 init.lua

### pkg-config

root@nineleven:~ # pkg-config --cflags --libs MagickWand
-I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -L/usr/local/lib -lMagickWand-6 -lMagickCore-6

### lib

root@nineleven:~ # ls -l /usr/local/lib/libMagickWand-6.so
lrwxr-xr-x  1 root  root  24 Feb 17 23:27 /usr/local/lib/libMagickWand-6.so -> libMagickWand-6.so.2.0.0

### nginx lua package

lua_package_path '/usr/local/share/lua/5.1/?/init.lua;/usr/local/etc/nginx/lua;;';

### nginx errors (variable)

2016/02/17 23:53:04 [error] 83225#101410: *1 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/magick/init.lua:163: Failed to load ImageMagick (MagickWand)
stack traceback:
coroutine 0:
[C]: in function 'require'
2016/02/18 00:46:43 [error] 83225#101410: *15 lua entry thread aborted: runtime error: /usr/local/etc/nginx/lua/serve_image.lua:36: loop or previous error loading module 'magick'
stack traceback:
coroutine 0:
[C]: in function 'require'


I've been looking for possible solutions, but I've exhausted ideas. Any ideas of how to solve this?. As I have already indicated, by changing the variables of nginx (ngx.*) by string and throwing in console with luajit, it works correctly. Thanks a lot.

Best regards.

Guanglin Lv

unread,
Feb 24, 2016, 5:51:13 AM2/24/16
to openresty-en


在 2016年2月23日星期二 UTC+8下午6:38:51,Anto写道:
Reply all
Reply to author
Forward
0 new messages