mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-04-10 02:36:46 +02:00
docs: Improve installation instructions, focus on LuaRocks installation (#454)
This commit is contained in:
parent
58c76080a0
commit
47e5bd71a9
@ -37,70 +37,30 @@ Installation">
|
|||||||
|
|
||||||
<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<h2>Installation</h2>
|
<h2>Installation via luarocks</h2>
|
||||||
|
|
||||||
<p> Here we describe the standard distribution. If the
|
|
||||||
standard doesn't meet your needs, we refer you to the Lua
|
|
||||||
discussion list, where any question about the package scheme
|
|
||||||
will likely already have been answered. </p>
|
|
||||||
|
|
||||||
<h3>Directory structure</h3>
|
|
||||||
|
|
||||||
<p> On Unix systems, the standard distribution uses two base
|
<p>LuaSocket can be easily installed using <a href="https://luarocks.org/" target="_blank">LuaRocks</a>, the Lua package manager.</p>
|
||||||
directories, one for system dependent files, and another for system
|
|
||||||
independent files. Let's call these directories <tt><CDIR></tt>
|
|
||||||
and <tt><LDIR></tt>, respectively.
|
|
||||||
For example, in my laptp, Lua 5.1 is configured to
|
|
||||||
use '<tt>/usr/local/lib/lua/5.1</tt>' for
|
|
||||||
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
|
|
||||||
<tt><LDIR></tt>. On Windows, <tt><CDIR></tt>
|
|
||||||
usually points to the directory where the Lua executable is
|
|
||||||
found, and <tt><LDIR></tt> points to a
|
|
||||||
<tt>lua/</tt> directory inside <tt><CDIR></tt>. (These
|
|
||||||
settings can be overridden by environment variables
|
|
||||||
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
|
|
||||||
documentation for details.) Here is the standard LuaSocket
|
|
||||||
distribution directory structure:</p>
|
|
||||||
|
|
||||||
|
<h3>Installing via LuaRocks</h3>
|
||||||
|
|
||||||
|
<p>Run the following command in your terminal:</p>
|
||||||
<pre class=example>
|
<pre class=example>
|
||||||
<LDIR>/ltn12.lua
|
luarocks install luasocket
|
||||||
<LDIR>/socket.lua
|
|
||||||
<CDIR>/socket/core.dll
|
|
||||||
<LDIR>/socket/http.lua
|
|
||||||
<LDIR>/socket/tp.lua
|
|
||||||
<LDIR>/socket/ftp.lua
|
|
||||||
<LDIR>/socket/smtp.lua
|
|
||||||
<LDIR>/socket/url.lua
|
|
||||||
<LDIR>/mime.lua
|
|
||||||
<CDIR>/mime/core.dll
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p> Naturally, on Unix systems, <tt>core.dll</tt>
|
<h3>Verification</h3>
|
||||||
would be replaced by <tt>core.so</tt>.
|
<p>To verify that LuaSocket is installed correctly, open Lua and run:</p>
|
||||||
</p>
|
<pre class=example><code>
|
||||||
|
local socket = require("socket")
|
||||||
|
print(socket._VERSION)
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
<h3>Using LuaSocket</h3>
|
<p>If you see output like <strong>LuaSocket 3.0</strong>, the installation was successful.</p>
|
||||||
|
|
||||||
<p> With the above setup, and an interpreter with shared library support,
|
<h3>More Information</h3>
|
||||||
it should be easy to use LuaSocket. Just fire the interpreter and use the
|
<p>For more details, visit the <a href="https://github.com/lunarmodules/luasocket" target="_blank">LuaSocket GitHub repository</a>.</p>
|
||||||
<tt>require</tt> function to gain access to whatever module you need:</p>
|
|
||||||
|
|
||||||
<pre class=example>
|
|
||||||
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
|
||||||
> socket = require("socket")
|
|
||||||
> print(socket._VERSION)
|
|
||||||
--> LuaSocket 3.1.0
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p> Each module loads their dependencies automatically, so you only need to
|
|
||||||
load the modules you directly depend upon: </p>
|
|
||||||
|
|
||||||
<pre class=example>
|
|
||||||
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
|
||||||
> http = require("socket.http")
|
|
||||||
> print(http.request("http://www.impa.br/~diego/software/luasocket"))
|
|
||||||
--> homepage gets dumped to terminal
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user