一、从Lua的官网(http://www.lua.org/)下载最新发布包,我下载的是lua-5.1.4.tar.gz发布包。
二、SecureCRT的rz命令上传lua-5.1.4到服务器上。使用tar -xzvf /lua-5.1.4.tar.gz命令解压缩,解压是一个lua-5.1.4文件夹。
三、使用cd /lua-5.1.4将当前工作目录,进入到lua-5.1.4文件夹中。
四、运行make命令,看到提示为:
Please do
make PLATFORM
where PLATFORM is one of these:
aix ansi bsd freebsd generic linux macosx mingw posix solaris
See INSTALL for complete instructions.
最后,运行make install命令
至此,lua语言环境已经顺利安装完成,在SecureCRT下输入lua命令进入lua命令行吧!
print('Hi,this is my first lua program!')
当然也可以变得更Lua一点:
io.write('Hi,this is my first lua program!'')
附上操作命令:
[root@localhost ~]# rz
[root@localhost ~]# tar -xzvf lua-5.1.4.tar.gz
[root@localhost ~]# cd lua-5.1.4
[root@localhost lua-5.1.4]# make
[root@localhost lua-5.1.4]# ls
[root@localhost lua-5.1.4]# cat /proc/version
[root@localhost lua-5.1.4]# make PLATFORM
[root@localhost lua-5.1.4]# make generic
[root@localhost lua-5.1.4]# make install
[root@localhost lua-5.1.4]# lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
>print('hi,this is my frist lua program')
hi,this is my frist lua program
>
可以建立*.lua文件,使用lua *.lua来运行
如果出现
libreadline.so: undefined reference to `tgetnum'
libreadline.so: undefined reference to `tgoto'libreadline.so: undefined reference to `tgetflag'
libreadline.so: undefined reference to `BC'
libreadline.so: undefined reference to `tputs'
libreadline.so: undefined reference to `PC'
libreadline.so: undefined reference to `tgetent'
libreadline.so: undefined reference to `UP'
libreadline.so: undefined reference to `tgetstr
的错误,则需要修改src内的makefile,在-lreadline后加上-lncurses即可解决