How do I install LiveCode Server on OS X 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 OS X 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. By default, OS X comes with Apache installed with the relevant files being contained in the folder /etc/apache2/.

To start Apache run this command from the Terminal

sudo apachectl start

If you are using a custom install of Apache, you will need to ensure that the 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?"

Download LiveCode Server

Begin by downloading the LiveCode server zip file for OS X 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.

Ensure LiveCode Server is executable

You will need to ensure the executable bit is set on the livecode-server file and the LiveCode Server folder.

Execute these commands in the terminal to set the executable bits

sudo chmod 755 ~/<path to LiveCode Server Folder>/

sudo chmod 755 ~/<path to LiveCode Server Folder>/livecode-server

Note: It may turn out that the folder containing the LiveCode Server folder also needs this to be done to it.

Accessing Apache configuration files

Accessing Apache configuration files

Next, you need to modify your Apache configuration files. To get access to you Apache configuration files, navigate to the folder /etc/apache2/.

To do this, open up finder, click on the "Go" menu, select "Go to Folder", type in /etc/apache2/ and click on "Go". This should open up a new finder window displaying the contents of the Apache folder.

Setup LiveCode Server as a CGI engine

Setup LiveCode Server as a CGI engine

The main Apache configuration file is "httpd.conf". In addition to "httpd.conf", each user has their own configuration file named "<username>.conf" located in the users sub-folder. If you find no such "<username>.conf" file in the users sub-folder, just create it; it does not require anything not mentioned immediately below. Open up the configuration file for your user in TextEdit and replace its contents with the following:

<Directory "/Users/<username>/Sites/">
  	 Options Indexes 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
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>
ScriptAlias /livecode-cgi/ <path to LiveCode Server folder>/

Here, <username> is the name of the user whose conf file you are editing (e.g. if your username were johnsmith, the directory would read /Users/johnsmith/Sites/) and <path to LiveCode Server folder> is the full path to the folder you unzipped the LiveCode Server files into (e.g. /Users/johnsmith/Desktop/LiveCodeServerPro-9_6_12-Mac/).

Note: If you have downloaded the pro version of LiveCode Server, be sure to change /livecode-cgi/livecode-server to /livecodecode-cgi/livecode-server-pro

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

Restart Apache

Once you have updated your configuration file, you must restart Apache. Do this by running the following command in the terminal:

sudo apachectl restart

Create & view a web page

Create &amp; view a web page

You are now ready to test your installation. To do this, create a file named "test.lc" in the "Sites" folder in the home folder of the user you have configured for. The "Sites" folder is the location for all the user's web pages.

To access the test script, navigate to http://localhost/~<username>/test.lc. 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

Trouble Shooting

If you cannot see the test page as expected you might need to change some other settings in the Apache configuration.

Ensure the required modules are enabled

To ensure the mod_cgi, mod_actions and mod_alias modules are enabled open the httpd.conf file in a text editor and ensure the following lines are uncommented.

LoadModule cgi_module libexec/apache2/mod_cgi.so
LoadModule actions_module libexec/apache2/mod_actions.so
LoadModule alias_module libexec/apache2/mod_alias.so
Click to copy

Ensure your Sites folder is accessible

To ensure your Sites folder is accesible you might need to make the following changes.

In the main httpd.conf file uncomment

LoadModule userdir_module libexec/apache2/mod_userdir.so

and

Include /private/etc/apache2/extra/httpd-userdir.conf

In extra/httpd-userdir.conf uncomment

Include /private/etc/apache2/users/*.conf

You may also need to grant access to the Sites folder itself.

sudo chmod 755 ~/Sites/

Allow LiveCode Server to run

In Catalina you might get messages that some of the LiveCode Server files are from an unidentified developer. If this happens you can run them anyway by opening System Preferences - Security & Privacy and choosing "Open Anyway" or choosing "Open Anyway" in any dialogs that popup.

This will be addressed in a future version of LiveCode Server.

Check your spelling

In particular, folder locations should end with a / and where absolute locations are intended, they should begin with a /.

29 Comments

Phil Davis

The "AddHandler" directive can take more than one suffix. Like this:

AddHandler livecode-script .lc .irev

So if some of your HTML/LiveCode pages are named with the .lc suffix and others have the .irev (or some other) suffix, you can include both suffixes in "AddHandler" and all your LC pages will be handled correctly.

Nick Iozzo

The option for web server is no longer on Mountain Lion. How do we get this to work on a Mac running Mountain lion?

Hanson Schmidt-Cornelius

Hi Nick,

Apple removed the Web Sharing option from the Sharing dialog in Mountain Lion but the apache server does still seem to be distributed with Mountain Lion.

Now there are many approaches you could take at this point and it is hard to say which one is best for you. The bottom line is that there is no nice button that does this for you anymore.

You approach may be to activate the apache server manually, by following various instructions that are described in many posts on the internet. You could also install other party applications that provide this kind of functionality for you.

Kind Regards,

Hanson

Dave Kilroy

I have OSX Server installed on Mavericks - what is my best route to installing LC Server?

Hanson Schmidt-Cornelius

Hi Dave,

this lesson and the following one:

http://lessons.runrev.com/spaces/lessons/buckets/809/lessons/36651

should cover all the information you need. Is there anything in particular you are having problems with?

Kind Regards,

Hanson

Joel Gerdeen

I am running LC Server with Mac OSX Mavericks and OSX Server. Using the Server app, I can easily turn Websites on and off to reset Apache. Also had to change execute access to the LC Server directory which I put in /Library/Server where other server files are stored. OSX Server also has a Alias feature to direct access to wherever you want to put the web page files.

Dave Kilroy

I've (at last!) got LiveCode Server working locally on a mac. A couple of notes - on Mavericks don't bother looking for a .conf file - and don't be as silly as me and think that "livecode-cgi" as a literal (once I changed it to "cgi-bin" it worked fine for me)

Dave Kilroy

Ach I can see that where I wrote 'opening tag' username 'closing tag' in my previous comment the system has swallowed it up and now is displaying a non-sensical ".conf"

So, in other words, in my case there was no "dave.conf" file, only a "Guest.conf" file in a subfolder - it seems that in Mavericks (and Mountain Lion too I think) you need to amend the httpd.conf file

Martin Koob

Regarding the lack of Web Sharing option from the Sharing Preference pane from Mac OS post Lion, I have encountered this issue while trying to set up LiveCode on a Mac with MacOS Sierra. I have found the following article which suggests a couple applications to get around this change.

https://computers.tutsplus.com/tutorials/3-ways-to-bring-back-web-sharing-in-os-x-mountain-lion--mac-45240

It suggests Anvil or MAMP. Has anyone tried either of these? Any comments or suggestions?

Torsten

Hi, the above link http://lessons.runrev.com/spaces/lessons/buckets/809/lessons/36651 doesn't work. Can you correct it?

Heather Laine

Thank you Torsten, I have corrected the links.

Stam

Hi all,
unfortunately this is out of date.

The 'Web sharing' option does not exist any more.
Apache still exists and i ensure it runs with "sudo apachectl start" in the terminal. I can confirm it works as 127.0.0.1 opens the test page with the test "It works!"

Unfortunately this lesson focuses on installing the server in a setting that doesn't exist anymore and I'm not sure how to proceed...

Would be grateful for guidance on this - thank you.

Stam

Has anyone had any luck installing this directly with the system bundled Apache server or with MAMP (given that 'Web Sharing' hasn't existed for a number of years?)

Elanor Buchanan

Hi Stam

To start Apache run this command from the Terminal.

sudo apachectl start

I have updated the lesson to reflect this. The rest of the setup steps still apply.

I hope that helps.

Kind regards

Elanor

stam

Thanks Eleanor, but i had already tried this and still couldn't get it to work...

I've edited the file /etc/apache2/httpd.conf as recommended above.

Unfortunately if i restart apache and put a test file with lc script in the server document directory, it just echoes the full script rather than showing the desired output... (I didn't want to clog the comments with details but will post a more detailed description of what i've done on the forums in the hope someone may be able to help...)

Elanor Buchanan

Hi Stam

It looks like there are a few addition configuration settings you might need to change. I have added another section to the lesson.

I hope that helps.

Kind regards

Elanor

Stam

Thank you Elanor - I have little expertise with apache but it seems the new modifications might be to enable 'personal web sharing' type access? (i.e. a http://localhost/ site?
If that is the case i guess more things may need to be modified to point to the /Users//Sites directory etc? And i guess the modifications above would be to the .conf rather than the httpd.conf file, as suggested in the older version in the lesson?

Stam

sorry that should have read "(i.e. a http://localhost// site)"

Stam

Sorry for the repeated messages - it seems that the word user surrounded by angulated brackets is removed from the text by the web site (i thought i had mis-typed but this is why you see localhost//, instead of localhost / (angle bracket) user (angle bracket). Weird.

Elanor Buchanan

Hi Stam

I have updated the lesson again. Have a look at the section I have added on "Ensure LiveCode Server is executable" and "Troubleshooting".

Please let us know how you get on.

Kind regards

Elanor

Andrew Taylor

Has this lesson been updated to reflect 9.6.8? Also the following link which was reported as not working, but then fixed, is not working: http://lessons.runrev.com/spaces/lessons/buckets/809/lessons/36651

Panos Merakos

Hello Andrew,

Yes, this lesson should work with LC Server 9.6.8 too. Are you having any issues?

The broken link should point to this lesson: https://lessons.livecode.com/m/4070/l/36651-how-do-i-install-livecode-server

Kind regards,
Panos
--

Andrew Taylor

I had my Apache and locahost working on macOS Ventura 13.1 - specifically PosterChild worked fine. I just downloaded Livecode server and installed it and followed the instructions to modify my user.conf file. NOW NOTHING WORKS FOR localhost!!

Andrew Taylor

BROKEN, BROKEN, BROKEN!!
This information is simply out of date and not usable as of Jan 28,2023. See https://forums.livecode.com/viewtopic.php?f=7&t=34553 where I provide files and details. We need a complete rewrite of this and somebody at RunRev needs to make NO ASSUMPTIONS and provide a public distribution version - not a "development test" type. (or state that Livecode simply no longer supports this functionality)

Panos Merakos

Hello Andrew,

Are you by any chance in a M1/M2 Mac? If yes, then for LC Server 9.6.7+, I think you have to make an extra step as described by Mark and Stam here:

https://forums.livecode.com/viewtopic.php?f=9&t=37437

You have to perform the tasks on every dylib file and on the livecode-server executable.

Let us know if this worked for you.

(Note: We will tweak what we do to the server engines we ship to make it work out of the box)

Kind regards,
Panos
--

Andrew Taylor

Hello Panos,
It has taken me a while to go backwards to a "clean" configuration and then implement the signature dance shown in the Forum. Now whether I have all changes in JUST the main httpd.conf file in /etc/apache2 or in a username.conf, I get the same result. It prints the contents of the .lc file, it does not EXECUTE that file. Yes I am using a new MacBook Pro 16 inch (Apple M1 Max) running MacOS 13.1. Ultimately I will want to run my code on a Mac Mini w/2.3 Ghz Intel Core i7 running macOS 10.12.6 w/whatever Apache shipped with it. Be nice if we had articles that are OS version oriented since it matters so much.

Panos Merakos

Hello Andrew,

I have just followed the lesson and setup LC Server 9.6.8 on a M1 mac mini running MacOS Ventura and an iMac running MacOS 10.13.x.

I noticed that the sample .lc script that was provided in this lesson did not show correctly in the lesson page - the page had "eaten" some of the html tags. This would explain why for you it prints the contents of the .lc file, and it does not execute that file.

I have now formatted the sample .lc code properly, so hopefully now it will work for you. Let me know if you still have problems.

Kind regards,
Panos
--

Andrew Taylor

Hi Panos,
After your prior response I went to that article by Mark and Stam and started over on a different machine trying to follow all the steps, including theirs AND IT WORKED! (the other machine was running 10.12, Apache 2.4, but NOT an M1,M2 - an Intel processor. Then I applied the same process to my M1 machine and it works too.
I have documented the steps needed to do this in exhaustive detail in two articles on the forum: "[SOLVED - partially] LC Server (Indy)" and "LiveCode Server and M2 processor? [SOLVED]". Possibly you guys could update the download and this article accordingly?
Thanks!

Panos Merakos

Hello Andrew,

Thank you for the update and the forum articles. The LC Server downloads will be updated sooner or later, so that users won't have to do this signature dance described in the forums. Until then, I'll update this lesson and include links to the forum articles.

Kind regards,
Panos
--

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.