Lua脚本发送http请求时报错: module 'socket' not found

在使用nginx发送http请求时报如下错误:

lua: ./socket/http.lua:11: module 'socket' not found:
	no field package.preload['socket']
	no file './socket.lua'
	no file '/usr/share/lua/5.1/socket.lua'
	no file '/usr/share/lua/5.1/socket/init.lua'
	no file '/usr/lib64/lua/5.1/socket.lua'
	no file '/usr/lib64/lua/5.1/socket/init.lua'
	no file './socket.so'
	no file '/usr/lib64/lua/5.1/socket.so'
	no file '/usr/lib64/lua/5.1/loadall.so'
stack traceback:
	[C]: in function 'require'
	./socket/http.lua:11: in main chunk
	[C]: in function 'require'
	lua.lua:3: in main chunk
	[C]: ?

具体解决办法如下:

1、wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz

Lua脚本发送http请求时报错: module 'socket' not found_第1张图片

2、tar -xzvf luasocket-2.0.2.tar.gz

Lua脚本发送http请求时报错: module 'socket' not found_第2张图片

3、cd luasocket-2.0.2

4、进入目录:luasocket-2.0.2,修改config文件

LUAINC=-I/usr/local/nginx/lua/zhangys/luasocket-2.0.2/src

LUAINC=-I/usr/local/openresty/luajit/include/luajit-2.1

Lua脚本发送http请求时报错: module 'socket' not found_第3张图片

5、make & make install

Lua脚本发送http请求时报错: module 'socket' not found_第4张图片

 

 

 

 

 

你可能感兴趣的:(Nginx)