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

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.  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 and <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

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:

  My LiveCode Server Test Page  

My LiveCode Server Test Page

Hello World! from LiveCode Server

" put "

The date is" && the date & "

" ?>

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

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

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.

20 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

Add your comment

E-Mail me when someone replies to this comment