安装luasocket

1).Lua 模块的安装和部署工具 LuaRocks
$sudo apt-get install luarocks  #安装部署工具 LuaRocks
$luarocks install luasocket

2).源码下载编译、安装
$git clone https://github.com/diegonehab/luasocket.git
$cd luasocket
$make
$make  install-both
$make test   #如果显示如下信息,恭喜你安装成功了!
lua test/hello.lua
Hello from LuaSocket 3.0-rc1 and MIME 1.0.3!

# luasocket makefile 
#
# see src/makefile for description of how to customize the build
#
# Targets:
#   install            install system independent support
#   install-unix           also install unix-only support
#   install-both       install for lua51 lua52 lua53
#   install-both-unix      also install unix-only
#   print              print the build settings

简单测试:

//luasocket_test.lua

#!/usr/local/bin/lua

local socket = require("socket")
print("hello luasocket")
print(socket._VERSION)  --输出luasocket版本信息

--运行结果(版本信息以实际安装版本为准)
hello luasocket
LuaSocket 3.0-rc1
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐