LiveCode LessonsHow To - LiveCode Server Tasks Installing LiveCode ServerHow do I install LiveCode Server on OS X with Apache?

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

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 enable Apache, you need to turn on "Web Sharing" from within the "Sharing" pane of "System Preferences", as in the image above.

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.

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

  Order allow,deny

  Allow from all

</Directory>

ScriptAlias /livecode-cgi/livecode-server <path to LiveCode Server folder>/livecode-server

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.

 

 

Restart Apache

Restart Apache

Once you have updated your configuration file, you must restart Apache.  You can do this by either turning "Web Sharing" on and off from the "Sharing" pane of "System Preferences" or 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.

8 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

Add your comment

E-Mail me when someone replies to this comment