How do I install LiveCode Server on Linux with Apache?
The LiveCode Server product brings our english like language to the server environment. The server engine is a separate build of the LiveCode engine with specific syntax and functionality that makes it suitable for use in command-line contexts and, in particular, as a CGI processor.
This lesson will walk you through the steps required to install LiveCode Server on Linux with Apache.
This lessons assumes you have access to your system's Apache configuration files. If you do not, see the the lesson "How to install LiveCode Server with Apache via .htaccess?"
Prerequisites
Before starting, read the lesson "How do I install LiveCode Server".
Apache is the most most popular web server package available today. Installing Apache will allow your machine to function as a web server, hosting websites and serving web pages. Most Linux distributions come with Apache installed by default. If not, you can either install it using the appropriate package manager for your system, download pre-built binaries for your system or build it from source.
For example, on Debian based distributions, you can install Apache using apt with the following command:
sudo apt-get install apache2
For more information on building Apache for your system, navigate to http://httpd.apache.org/docs/2.0/install.html.
You will need to ensure that your install of Apache has following three modules are enabled:
This lessons assumes you have access to your system's Apache configuration files. If you do not, see the the lesson "How to install LiveCode Server with Apache via .htaccess?"
32bit libraries are required for LiveCode server to run on a 64bit Linux distribution
These can be installed via the following (or similar) commands-
yum install glibc.i686 glibc-2.12-1.107.el6_4.2.i686
yum install libgcc.i686
Download LiveCode Server
Begin by downloading the LiveCode server zip file for Linux using the instructions detailed in the lesson "How do I install LiveCode Server?". Unzip the package into your desired location - for example in your home folder.
Access Apache configuration files
The location of your Apache configuration files will depend upon the setup of your system. Â They are often located located in either in /etc/apache2/ or /etc/httpd/. There is usually on main httpd.conf file in this folder that includes several sub configuration files. For example, on Debain based systems, the site configuration is often included in a sub folder /sites-enabled/.
Set up LiveCode Server as a CGI engine
Next, you need to alter the Apache configuration file so that it associates .lc extensions with the LiveCode Server engine. To do this, open up the main Apache configuration file in a text editor. Your configuration file should contain an entry like the following:
DocumentRoot /var/www
This details the folder where Apache looks for its web pages. This folder will have a directory directive that by default will look something like the following:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler livecode-script .lc
Action livecode-script /livecode-cgi/livecode-server
</Directory>
Update this directory directive to look like the following:
<Directory "/var/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler livecode-script .lc
Action livecode-script /livecode-cgi/livecode-server
</Directory>
<Directory "<path to LiveCode Server folder>">
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
ScriptAlias /livecode-cgi/livecode-server "<path to LiveCode Server folder>/livecode-server"
Here <path to LiveCode Server folder>
is the full path to the folder you unzipped the LiveCode Server files into.
Important: These instructions apply to Apache v2.2. If you are using a newer version of Apache, you need to replace every occurence of:
Order allow,deny
Allow from all
with
Require all granted
Restart Apache
Once you have updated your configuration file, you must restart Apache. You can do this by running the following command in the terminal (may vary, depending upon you Apache install):
sudo apache2ctl restart
Create and view a test page
You are now ready to test your installation. To do this, create a file named "test.lc" in your document root folder. Your document root folder is defined in your Apache configuration file and can be found using the interactions defined in the step "Set up LiveCode Server as a CGI engine".
To access the test script, navigate to http://localhost/test.lc using your browser. The above image shows the expected output if "test.lc" contains the following script:
<html>
<head>
<title>My LiveCode Server Test Page</title>
</head>
<body>
<h1>My LiveCode Server Test Page</h1>
<?lc
put "<p>Hello World! from LiveCode Server</p>"
put "<p>The date is" && the date & "</p>"
?>
</body>
</html>
For more detailed information on installing LiveCode server, see the server release notes distributed with the server package.
NB: Depending on your Linux install you may need to set ownership/permissions of livecode-server file
e.g.
chown owner-user livecode-server
When something appears to have gone wrong with the setup of LiveCode Server, it is best to consult Apache's error log, which should help you ascertain the nature of the problem. Typically, this can be located at /var/log/apache2/error.log
Amanda
I have set everything up as per instructions above but when I navigate to test.lc in a browser I see the hmtl script instead of the livecode expected output. I didn't get any release notes when I downloaded the server software so I cannot refer back to it.
Does the result I'm getting have a known fix?
I'm thinking the changes I've made to the directives in httpd.conf file are not correct.
Hanson Schmidt-Cornelius
Hi Amanda,
when you say you see the html script instead, what does that mean? Are you seeing the LiveCode script source, rather than the output you would have expected, had the LiveCode script been executed? Are you seeing text that is HTML formatted? Or are you seeing something else?
Kind Regards,
Hanson
Amanda
Hi Hanson,
This is what I saw when navigating to test.lc:
My LiveCode Server Test Page
My LiveCode Server Test Page
Hello World! from LiveCode Server"
put "
The date is" && the date & "
"?>
Cheers, Amanda
Hanson Schmidt-Cornelius
Hi Amanda,
from the information you have provided, it is hard to determine exactly what may not be working correctly.
Our first assumption is that there is something wrong with your httpd.conf file.
Have a look in there to see if all the configuration information appears to be set up properly.
Kind Regards,
Hanson
Russell Martin
I just did this on Ubuntu Server 14.04.
These directions do *NOT* work for this distro and it's apache configuration files.
To install live code server on Ubuntu Server 14.04 (assuming you chose the LAMP server option on install), the process is more like this:
To enable the required mods:
(I'm using hyphens as bullet points, they aren't part of the commands.)
- sudo a2enmod cgi
- sudo a2enmod alias
- sudo a2enmod actions
To enable the 32 bit libraries:
(http://askubuntu.com/questions/454253/64bit-ubuntu-14-04-running-32bit-binaries)
- sudo dpkg --add-architecture i386
- sudo apt-get update
- sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
You wanna put the livecode-server binary in /usr/lib/cgi-bin, so start from whichever directory you downloaded the livecode-server.zip file to:
- sudo cp /usr/lib/cgi-bin/
- cd /usr/lib/cgi-bin/
- (You'll probably have to install unzip, I did. "sudo apt-get install unzip")
- sudo unzip
- sudo chmod a+x livecode-server (or, livecode-community-server)
You don’t wanna mess with the /etc/apache2/apache2.conf file at all. Just leave it alone.
You’re simply gonna make a few adjustments to /etc/apache2/sites-enabled/000-default.conf
So to edit it:
(If you don’t know how to edit with vi, then use something easier, like pico instead of vi)
- sudo vi /etc/apache2/sites-enabled/000-default.conf
If you’ve unzipped the livecode-server (or livecode-community-server) in /usr/lib/cgi-bin then you only need to add 2 lines to 000-default.conf and to uncomment one line.
Right below where it says “DocumentRoot /var/www/html” add the following 2 lines (don’t include the hyphens):
- AddHandler livecode-script .lc
- Action livecode-script /cgi-bin/livecode-server
(Note: If you’re using community edition, you should put /cgi-bin/livecode-community-server -OR- in the /usr/lib/cgi-bin/ directory make a symlink as follows “sudo ln -s livecode-community-server livecode-server, if you create this symlink, you can just refer to it as livecode-server)
Now, at the bottom of the file, uncommment (by deleting the #) this line:
Include conf-available/serve-cgi-bin.conf
Save the file and restart apache2:
- sudo service apache2 restart
Basically, the default configuration for apache2 in Ubuntu Server is all ready to go for cgi executables located in /usr/lib/cgi-bin. /etc/apache2/apache2.conf references a few other files that define a default virtual host in /var/www/html and so making the modifications to apache2.conf that this document recommends will get ignored or overridden by these other files. So, by placing the livecode-server file and externals in the expected place and then enabling cgi for the default host (and defining the handler and action), you’re good to go. Just place a test.lc file in /var/www/html and watch it run.
I hope this saves someone the hours of frustration that I went through before I got it to work.
Oh, and if you want to be able to execute scripts at the server command line without having to put the full path to livecode-server (or livecode-community-server) just make a symlink in your /usr/local/bin directory so that it can be found in your path:
- sudo ln -s /usr/lib/cgi-bin/livecode-server /usr/local/bin/livecode-server
Russell Martin
Sorry, reposting because everything I put in greater than, less than brackets became invisible. Maybe the mods can delete the previous version of my post?
I just did this on Ubuntu Server 14.04.
These directions do *NOT* work for this distro and its apache configuration files.
To install live code server on Ubuntu Server 14.04 (assuming you chose the LAMP server option on install), the process is more like this:
To enable the required mods:
(I'm using hyphens as bullet points, they aren't part of the commands.)
- sudo a2enmod cgi
- sudo a2enmod alias
- sudo a2enmod actions
To enable the 32 bit libraries:
(http://askubuntu.com/questions/454253/64bit-ubuntu-14-04-running-32bit-binaries)
- sudo dpkg --add-architecture i386
- sudo apt-get update
- sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
You wanna put the livecode-server binary in /usr/lib/cgi-bin, so start from whichever directory you downloaded the livecode-server.zip file to:
- sudo cp [Name of livecode-server.zip] /usr/lib/cgi-bin/
- cd /usr/lib/cgi-bin/
- (You'll probably have to install unzip, I did. "sudo apt-get install unzip")
- sudo unzip [Name of livecode-server.zip]
- sudo chmod a+x livecode-server (or, livecode-community-server)
You don’t wanna mess with the /etc/apache2/apache2.conf file at all. Just leave it alone.
You’re simply gonna make a few adjustments to /etc/apache2/sites-enabled/000-default.conf
So to edit it:
(If you don’t know how to edit with vi, then use something easier, like pico instead of vi)
- sudo vi /etc/apache2/sites-enabled/000-default.conf
If you’ve unzipped the livecode-server (or livecode-community-server) in /usr/lib/cgi-bin then you only need to add 2 lines to 000-default.conf and to uncomment one line.
Right below where it says “DocumentRoot /var/www/html” add the following 2 lines (don’t include the hyphens):
- AddHandler livecode-script .lc
- Action livecode-script /cgi-bin/livecode-server
(Note: If you’re using community edition, you should put /cgi-bin/livecode-community-server -OR- in the /usr/lib/cgi-bin/ directory make a symlink as follows “sudo ln -s livecode-community-server livecode-server”, if you create this symlink, you can just refer to it as livecode-server)
Now, at the bottom of the file, uncommment (by deleting the #) this line:
Include conf-available/serve-cgi-bin.conf
Save the file and restart apache2:
- sudo service apache2 restart
Basically, the default configuration for apache2 in Ubuntu Server is all ready to go for cgi executables located in /usr/lib/cgi-bin. /etc/apache2/apache2.conf references a few other files that define a default virtual host in /var/www/html and so making the modifications to apache2.conf that this document recommends will get ignored or overridden by these other files. So, by placing the livecode-server file and externals in the expected place and then enabling cgi for the default host (and defining the handler and action), you’re good to go. Just place a test.lc file in /var/www/html and watch it run.
I hope this saves someone the hours of frustration that I went through before I got it to work.
Oh, and if you want to be able to execute scripts at the server command line without having to put the full path to livecode-server (or livecode-community-server) just make a symlink in your /usr/local/bin directory so that it can be found in your path:
- sudo ln -s /usr/lib/cgi-bin/livecode-server /usr/local/bin/livecode-server
Seth Morrow
@Russell Martin: Thank you, thank you , thank you.
Pascal
Is this "32bit libraries are required" part still true for the 64bit version of LC Server?
This is a problem for 64bit only servers..
john smith
Nice
Sphere
The lesson should be upgraded to what Russel Martin describes, in apache2.4 there is no httpd.conf anymore
Sam
Running LC Server 64 bit on Linux Debian 10 64 bit without need for 32bit libraries.
Here is my configuration :
1. upload & extract LiveCode server to /usr/lib/cgi-bin
2. change the owner user to www-data
3. edit /etc/apache2/apache2.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
AddHandler livecode-script .lc
Action livecode-script /livecode-cgi/livecode-server
Options ExecCGI
Require all granted
ScriptAlias /livecode-cgi/livecode-server /usr/lib/cgi-bin/livecode-server
4. create test.lc on /var/www/html
5. restart apache
browse to http://192.169.0.1/test.lc and got the "Internal Server Error"
look at the /var/log/apache2/error.log found "error while loading shared libraries: libfontconfig.so.1"
base on this https://stackoverflow.com/questions/45129742/error-while-loading-shared-libraries-libfontconfig-so-1-on-cent-os/45129811
I fixed the error with : sudo install fontconfig
and the server is working.