How to Instal LiveCode Server on OS X Server

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am
Location: Sydney, Australia

How to Instal LiveCode Server on OS X Server

Post by icouto » Wed May 21, 2014 7:10 am

I was wondering whether there are any instructions for installing LiveCode Server on a OS X Server? - the official guides only talk about altering httpd.conf files in a client machine.

Although the server software is the same (Apache) for both client and server OS X, the setup on OS X Server is different: Apple has config files all over the place, and these seem to get over-written on every update, so I wanted to avoid hacking httpd.conf files directly. I tried doing the setup via ".htacess", but the instructions for that don't work either - by default, OS X Web Server doesn't create a neat "cgi-bin" for your sites, for you to put your executables inside.

I found out that Apple seemingly wants you to put all your executables in /Library/WebServer/CGI-Executables/, so I tried:

1) putting the "livecode-server" executable (and its accompanying folders) inside /Library/WebServer/CGI-Executables/

2) adding a .htaccess file at the root of my site, with the following lines:

Code: Select all

Options ExecCGI
AddHandler livecode-script .lc
Action livecode-script /cgi-bin/livecode-server
If I do this, and then try to run a test script (index.lc), I get a 404 server error:

Code: Select all

NOT FOUND
The requested URL /cgi-bin/livecode-server/index.lc was not found on this server.
I tried changing the "Action" line in the ".htaccess" file to:

Code: Select all

Action livecode-script /cgi-executables/livecode-server
And even tried:

Code: Select all

Action livecode-script /livecode-server
But nothing works - I keep getting the same error...

Would anyone have any suggestions? Any guidance would be much appreciated.

icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am
Location: Sydney, Australia

Re: How to Instal LiveCode Server on OS X Server

Post by icouto » Thu May 22, 2014 9:02 am

I found a solution, and therefore am posting it here for reference, in case others need it, too.

In OS X Server Mavericks, the appropriate location to put cgi executables (parsers and interpreters), is NOT /Library/WebServer/CGI-Executables, but /Library/Server/Web/Data/CGI-Executables.

The step-by-step installation instructions for LiveCode Server on OS X Server, via .htaccess are:

1. Download the LiveCode server zip archive from livecode.com, unzip it, and place its contents in your Server's /Library/Server/Web/Data/CGI-Executables folder. These should be the "livecode-server" executable, and its accompanying folders.

2. Make sure all livecode-server files and folders have permissions set to "755". If you downloaded the files directly to your OS X Server machine and extracted them there, you should not have a problem. If, however, you have transferred the files to your server via ftp or some other remote protocol after unzipping them, their permissions may have changed. Most ftp software allow you to check - and change - a file's permissions, but you can also do this on the Terminal, using the "ls -l" to check permissions, and "chmod" to change them.

3. In your site's home folder, add a .htaccess file with the following content:

Code: Select all

Options ExecCGI
AddHandler livecode-script .lc
Action livecode-script /cgi-bin/livecode-server
4. In Server.app, in your site's Advanced settings, make sure you enable the "Allow overrides using '.htaccess' files" option.

You should now be able to place a test.lc file in your home directory, with some livecode-server code, and see it run - like this:

Code: Select all

<html>
  <head>
    <title>LiveCode Server Test</title>
  </head>
  <body>
    <?lc
    put "<h1>Hello World!</h1>
    put "<p>" & the long date && "@" && the time "</p>
    ?>
  </body>
</html>
I would still like to know how to setup LiveCode Server on OS X Server via httpd.conf. If anyone has done this, and can provide guidance, that would be truly appreciated.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: How to Instal LiveCode Server on OS X Server

Post by dave.kilroy » Thu May 22, 2014 10:22 am

Hi icouto

After a lot of hair-tearing, blood on the floor and help from others - I eventually managed to install LC server on Mavericks (sadly not server) using the httpd.conf route - DM me if you would like me to send you a copy...

Kind regards

Dave
"...this is not the code you are looking for..."

UKenGB
Posts: 16
Joined: Mon Aug 25, 2014 11:06 am

Re: How to Instal LiveCode Server on OS X Server

Post by UKenGB » Wed Feb 21, 2018 6:20 pm

I'm sure others have figured this out by now, but I've not seen it written up, so this is how I did it on MacOS 10.13 High Sierra:-

First of all, MacOS Server keeps all this stuff in /Library/Server/Web so that's where to start looking.

Then, I didn't want to use .htaccess file(s), nor did I want to modify the main httpd server (i.e. Apache) conf file. Not that I'm afraid of doing it, but come next update time, Apple will likely stuff a new one in there and bye bye my carefully crafted config. However there's some interesting lines at the end of that file:-

Code: Select all

<IfDefine WEBSERVICE_ON>
    Include /Library/Server/Web/Config/apache2/sites/*.conf
</IfDefine>
<IfDefine !WEBSERVICE_ON>
    Include /Library/Server/Web/Config/apache2/sites/virtual_host_global.conf
    Include /Library/Server/Web/Config/apache2/sites/0000_127.0.0.1_34580_.conf
    Include /Library/Server/Web/Config/apache2/sites/0000_127.0.0.1_34543_.conf
</IfDefine>
This means that if WEBSERVICE is ON, it will include ANY .conf file in that sites folder but NOT if WEBSERVICE is OFF. So if we add our own conf file in ....sites, it will be used as appropriate, just as we want.

So I created the /Library/Server/Web/config/apache2/sites/lc-cgi.conf file (use any name as long as it ends .conf) with the following content:-

Code: Select all

AddHandler livecode-script .lc
Action livecode-script /cgi-bin/livecode-server
#
<Directory "/Library/Server/Web/Data/CGI-Executables">
    Options +FollowSymLinks
</Directory>
So this will cause apache to pass any .lc file to the livecode-server file in CGI-Executables because the main .conf file sets up the ScriptAlias that will substitute that directory for the cgi-bin in the Action directive. Doing it this way seems to ensure apache is happy to execute what it needs to 'run' any .lc file you want in your web site.

But what is that livecode-server in CGI-Executables?

Since I wanted to be able to access the lc server from outside the web server setup, I placed the uncompressed server files into a directory named including the version number and in /usr/local. In fact I have both 8.1.9 and 9.0.0 in there and then a symlink in CGI-Executables to the appropriate LiveCode Server binary I want to use. Hence the requirement for the +FollowSymLinks option in the lc-cgi.conf as otherwise it fails since it cannot get to that actual server binary.

So, this works on my MacOS High Sierra Server, I can enable or disable CGI ability for each web site using Apple's Server.app and by simply changing the symlink in CGI-Executables I can switch between different versions of LiveCode Server.

Also, with the server in /usr/local and the desired version accessible via a symlink in /usr/local/bin, I can execute any .lc script file directly just with that hashbang (aka shabang, shebang etc) first line, as I wrote about in another topic.

I do love it when a plan comes together. :D

Post Reply

Return to “CGIs and the Server”