How Do You Install the Lua Compiler on a CentOS/RHEL/Fedora Server?

Problem scenario
You want to run Lua programs on your Red Hat derivative distribution of Linux server (e.g., CentOS/RHEL/Fedora).  

Solution
1.  Make a script like this called lua.sh with the following lines:

yum -y install readline-devel gcc
curl https://www.lua.org/ftp/lua-5.3.5.tar.gz > /tmp/lua-5.3.5.tar.gz
mv /tmp/lua-5.3.5.tar.gz /opt/
cd /opt/
tar -xzvf lua-5.3.5.tar.gz
cd lua-5.3.5
sudo make linux test
echo "ENV=$ENV:/opt/lua-5.3.5/src/" >> /etc/environment
rm /usr/bin/lua
ln -s /opt/lua-5.3.5/src/lua /usr/bin/lua
a=$(lua -v)
echo $a

2.  Run the script with this command: sudo bash /tmp/lua.sh

Leave a comment

Your email address will not be published.