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.