How do I install LiveCode Server with Apache via .htaccess?
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.
If you are trying to set up LiveCode Server on a shared server, it will often be the case that you do not have access to the server's Apache config file. In this situation, you can configure LiveCode Server using a .htaccess file. This lesson will walk you through the steps required to install LiveCode Server with Apache using .htaccess files.
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. If you do not have Apache set up on your systems already, you will need to download and install the latest version. Apache installers for Apache can be found here: http://httpd.apache.org/download.cgi#apache22.
If you are trying to set up LiveCode Server on a shared server, it will often be the case that you do not have access to the server's Apache config file. In this situation, you can configure LiveCode Server using a .htaccess file. In order to use this method, your Apache installation will need to have .htaccess file enabled (http://httpd.apache.org/docs/current/howto/htaccess.html).
Additionally, you will need to ensure that the following three Apache modules are enabled:
These modules are usually enabled. If not, contact your service provider or server administrator to see if they will set them up for you.
Using .htaccess file is not the recommended method of configuration. If you have access to your server's Apache configuration files, you should follow the steps in the lesson appropriate for your platform:
- How do I install LiveCode Server on OS X with Apache
- How do I install LiveCode Server on Windows with Apache
- How do I install LiveCode Server on Linux with Apache
Download LiveCode Server
Begin by downloading the LiveCode server zip file using the instructions detailed in the lesson "How do I install LiveCode Server". Unzip the package and upload it to your "cgi-bin" folder.
Create your .htaccess file
In your "public_html" folder create a file name ".htaccess" with the following content:
AddHandler livecode-script .lc Action livecode-script /cgi-bin/livecode-server
This file will tell Apache to map files with a .lc extension to livecode-script files, which should then get executed by the LiveCode Server CGI.
Create & view a web page
You are now ready to test your set up. To do this, create a file named "test.lc" in your "public_html" folder on your server. To access the test script, navigate to http://<your host>/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.
Hello, Thanks for this lesson ! I try to install Livecode community server on a Linux server via .htaccess but when I access to test.lc with a browser, I see only "ELF". I don't understand why.
This sounds like this bug https://quality.livecode.com/show_bug.cgi?id=19293, which is fixed in the most recent versions of LC Server. I suggest using either LC Server 8.1.10 or LC Server 9.0.0.
Thanks for your comment. I tried with LC community server 8.1.10 and 9.0.0 (stable), but I have the same "ELF".
Hi all - it's been a struggle to get LC Server running on MacOS Catalina and Apache 2.4. I've still not managed to get the other method of running this to work (ie by editing the httpd.conf file), but I was finally able to get this running with an .htaccess file -- however beware there are missing steps in this lesson, without which it fails.
Use BBEdit - best way to edit Wheel-owned documents.
The cgi-bin folder is located in /Library/WebServer/CGI-Executables/
The served documents (.html and .lc) go into the folder /Library/WebServer/Documents/
The apache installation lives in the folder /etc/apache2/
1. Put all the 'server' files you downloaded in this cgi-bin folder (the 'livecode-server' file, the 'drivers' and 'externals' folders)
2. Use Terminal.app to navigate to this folder and make the 'livecode-server' file executable by running chmod:
sudo chmod 755 livecode-server
3. Using BBEdit, open the file: /etc/apache2/httpd.conf and uncomment these lines (remove the #):
#LoadModule cgid_module libexec/apache2/mod_cgid.so
#LoadModule cgi_module libexec/apache2/mod_cgi.so
#LoadModule actions_module libexec/apache2/mod_actions.so
#LoadModule alias_module libexec/apache2/mod_alias.so
(this last one was already uncommented in my httpd.conf file, but make sure yours is too).
4. In httpd.conf, in the section scroll down to the section that allows .htaccess to run directives (described in comments) and change 'AllowOverride None' to 'AllowOverride All' and save your file.
5. In BBEdit, create new file with the following text:
AddHandler livecode-script .lc
Action livecode-script /cgi-bin/livecode-server
Save this file in the directory /Library/WebServer/Documents/ with the name '.htaccess'
6. Restart apache: sudo apachectl restart
Now i can correctly render http://localhost/test.lc
In summary, I could only make this work by adding these seemingly missing steps:
- Making livecode-server executable (sudo chmod 755 livecode-server)
- Setting AllowOverride None to Allow Override All (in/etc/apache2/httpd.conf file, in the section )
- Adding the line 'Options ExecCGI' to the .htaccess file
I don't know if any/all of these are really needed, but seemed to be required for this to work for me...
For what it's worth, this works with MAMP as well (i've only tested apache, not nginx)
On Mac, the relevant files are in /Applications/MAMP/
The default httpd.conf in /conf/apache/ is configured correctly and needs no modification.
Save the above .htaccess file to the 'htdocs' folder
Copy the server files to the cgi-bin folder
Make the livecode-server executable as above.
Put your test file in the 'htdocs' folder and restart the server.
As the default port for MAMP is 8888, you can render your test file with the URL http://localhost:8888/test.lc.
(this works fine in parallel with the built-in apache on port 80)