Page 1 of 2

[SOLVED - partially] LC Server (Indy)

Posted: Tue Aug 25, 2020 1:27 am
by stam
Hi all,

Having scoured the lessons and any links i could find (i could find almost none other than the Lessons), i'm stumped installing LC server on Catalina..
Is there an up-to-date guide for installing LC server on for MacOS Catalina?

The current lessons don't apply to the zsh shell (and yes i have read/write permissions to the directory and all enclosed items):

Code: Select all

 ./livecode-server myscript.lc     //run in the LC server directory as suggested in the corresponding Lesson

zsh: permission denied: ./livecode-server
While apache is still installed with the OS, the Web sharing option in the Sharing... control panel has been removed.
So none of the lessons apply (there is no functional user sites folder, there is no <user>.conf file i could find, etc).

Apache is running & functional for the machine (ie 'localhost' shows the 'it works' page). But really can't get LC Server to work with this (admittedly my knowledge of Apache is very limited...).

Very grateful if an expert could provide some guidance on this, or point to an up-to-date guide...

Re: LC Server (Indy)

Posted: Tue Aug 25, 2020 1:45 am
by FourthWorld
What are the permissions for that executable file?

Re: LC Server (Indy)

Posted: Tue Aug 25, 2020 2:15 am
by stam
Made the mistake of relying on finder-reported permissions but of course these don't include the executable bit. Permissions were set to rw- r-- r--
The lessons should maybe point out...

I chmod'd the folder and its contents to 777 (temporarily anyway) and it works - thank you (for anyone else not sure about this, have a look here)

All 3 dylibs in the Externals folder (revdb.dylib, revxml.dylib, revzip.dylib) were then blocked by gatekeeper but that's simple to address

However, i imagine the main value of server is running it as cgi?
Still can't figure out how to get that up and running...

Re: LC Server (Indy)

Posted: Tue Aug 25, 2020 2:52 am
by FourthWorld
You may want to change that from 777 to 700.

Do you have Apache installed?

I haven't used a Mac as a server in more than a decade, but this may help:

http://lessons.livecode.com/m/4070/l/36 ... ith-apache

Re: LC Server (Indy)

Posted: Tue Aug 25, 2020 8:45 am
by stam
FourthWorld wrote:
Tue Aug 25, 2020 2:52 am
I haven't used a Mac as a server in more than a decade, but this may help:
http://lessons.livecode.com/m/4070/l/36 ... ith-apache
Thanks Richard, that was the first thing i checked... Unfortunately the lesson is well out of date.
The 'Web sharing' option does not exist any more.
Apache still exists and i ensure it runs with

Code: Select all

sudo apachectl start
and i can confirm it works as 127.0.0.1 opens the test page with the test "It works!"

Unfortunately the lesson focuses on installing the server in a setting that doesn't exist anymore and I'm not sure how to proceed... I'll post a comment in the lesson as well, maybe the team may be able to respond directly there.

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 12:26 am
by stam
Hi all,
still hoping to get some help with this as i can't get the server to work in cgi mode on mac.
I've tried to follow the lesson on installing with apache on mac, adapting it for current MacOS as the lesson is outdated.

Apache works and serves up files in /Library/WebServer/Documents
There is no <user>.conf file in /etc/apache2/ since they removed personal web sharing, so i edited the /etc/apache2/httpd.conf file
I've put the server cgi-bin files in my home folder (/Users/stam/LCS), so i've modified the httpd.conf file to:

Code: Select all

<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks Multiviews   	##  FollowSymLinks was already set in httpd.conf, i left this unchanged
    MultiviewsMatch Any 				##  Already in httpd.conf, i left this unchanged
    AllowOverride None
    Require all granted
    AddHandler livecode-script .lc
    Action livecode-script /livecode-cgi/livecode-server
</Directory>

Code: Select all

<Directory "/Users/stam/LCS"
     Options ExecCGI
     Require all granted
</Directory>

Code: Select all

ScriptAlias /livecode-cgi/livecode-server Users/stam/LCS/livecode-server
After restarting apache in terminal (sudo apachectl restart), putting the sample script file in /Library/WebServer/Documents just echoes the text of the file instead of showing the desired output... ie: http://127.0.0.1/test.lc in a browser just shows:
<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>

With the 2 minor exceptions in httpd.conf (i left a couple of statements unchanged as didn't want to risk changing the default settings) i've followed the instructions faithfully, albeit by editing the httpd.conf instead of the <user>.conf file, but can't seem to get it to work...

Has anyone had experience with this and is able to point out what i've done wrong?

-------
EDIT: I realised the default httpd.conf in /etc/apache2/ may not be loading the required mod_cgi, mod_actions and mod_alias modules; I've uncommented lines containing references to these presuming this will allow them to load on restarting apache. However now instead of echo'ing the script as above, i just get a 403: Forbidden/you don't have access to this resource

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 3:51 am
by ghettocottage
Just to get a better picture of what is going on, can you explain how you set up Apache? Was it already installed? Did you do any sort of custom configurations? I am familiar with Apache but not on Catalina.

From what I have read, the default location to place CGI programs for the Mac apache installation is in the following directory:
/Library/WebServer/CGI-Executables


if that is true:

Then you would open a terminal window (Applications -> Utilities -> Terminal). Execute the following command:

cd /Library/WebServer/CGI-Executables

Then execute the following (if prompted, enter your password)

sudo chmod 755 livecode-server
sudo chmod +x livecode-server

add this to your user.conf apache file

AddHandler livecode-script .lc
Action livecode-script /cgi-bin/livecode-server
ScriptAlias /cgi-bin/ /Library/WebServer/CGI-Executables/



restart apache


no guarantees, but worth a shot

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 11:52 am
by elanorb
Hi Stam

I have replied to your lesson comment but I wanted to reply here too in case it helps anyone else. I think there are a few http configuration settings that were not mentioned in the lesson. I have added another section to it which I will copy here.

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

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

I hope that helps. Please let me know if not.

Kind regards

Elanor

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 3:03 pm
by stam
Thanks both, but still can't get it to work...

As a clarification i'm using the built-in, unmodified apache installation on Catalina. I've made copies of any .conf files so i can always work off a fresh copy as i'm paranoid i'll cause irreversible damage otherwise ;)

I've put a small html file along side the small lc script in the main web server document directory. Almost always i can get the html to work but have yet to get the .lc to work.
127.0.0.1 -> shows the test page with the text 'It works!'
127.0.0.1/test.html shows my small test html file correctly (almost always)
127.0.0.1/test.lc fails every time (the lc script is seen in my post above)

@ghettocottage -- i tried your recommendations, now i just get 'server can't be found' error when truing to run an lc script, while the html continues to render correctly

@Elanor -- i uncommented your lines but that makes no difference to the lc script and while it shows the 'it works!' page, i can now no longer render my test html file correctly ('can't connect to server' error).

@Elanor -- are the changes you proposing for user based sites? (ie. should the previous edits in the lesson be made in a <user>.conf file instead of the httpd.conf file?)

If anyone has a working version of an httpd.conf file (and if you've modified it, the extra/httpd-userdir.conf file), would you mind posting them (or pinging me a copy)?

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 3:53 pm
by ghettocottage
Just glancing through some online info about apache on OS X, some tutorials are saying to put your scripts into the cgi folder, and make them exectuable.
So your index.lc file would go into /Library/WebServer/CGI-Executables

then you would (from command):
cd /Library/WebServer/CGI-Executables

sudo chmod +x index.lc


then access that from: http://localhost/cgi-bin/index.lc


I do not have a mac so I cannot test this.

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 7:19 pm
by stam
thanks @ghettocottage... it hadn’t occurred to me to make the LC scripts executable so will be interesting to try when a get a chance (but for now busy with my actual day job!)

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 7:33 pm
by ghettocottage
I do not have to make my scripts executable on my Ubuntu server running apache and livecode server, but several of the Mac OS tutorials I ran across on running a CGI script of various types all said they do that. Not sure why

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 8:23 pm
by stam
Hmmm still no luck... thought i'd maybe start afresh with an untouched httpd.conf file again and compared with a linux install described on howtoforge, as it looked pretty similar to my attempt (see the code at the end of the linked page).

Apache 2.4 on Catalina. As per the suggestion in the LiveCode lesson, i've put the server files in my home directory and this is referenced in the httpd.conf file (the directory for the server is /Users/stam/LCS/)

In the httpd.conf file, I uncommented the lines

Code: Select all

<IfModule !mpm_prefork_module>
	LoadModule cgid_module libexec/apache2/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
	LoadModule cgi_module libexec/apache2/mod_cgi.so
</IfModule>
and

Code: Select all

LoadModule actions_module libexec/apache2/mod_actions.so
The line

Code: Select all

LoadModule alias_module libexec/apache2/mod_alias.so
was already uncommented.
This should, if i've understood correctly, load the modules stated as required in the lesson.

Also according to the lesson, as i'm running apache 2.4, i've replaced the example code

Code: Select all

Order allow,deny
Allow from all
with

Code: Select all

Require all granted
I've edited the httpd.conf file:

Code: Select all

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks Multiviews
    MultiviewsMatch Any
    AllowOverride None
    Require all granted
    AddHandler livecode-script .lc
    Action livecode-script /livecode-cgi/livecode-server
</Directory>

<Directory /Users/stam/LCS>
Options ExecCGI
Require all granted
</Directory>

ScriptAlias /livecode-cgi/ /Users/stam/LCS/
the only difference from the lesson i've included is the FollowSymLinks and MultiviewsMatch Any as these were already in the httpd.conf file and also in the howtoforge example. The howtoforge also includes trailing slashes for the directories in ScriptAlias, which i've also included.

With these settings, the apache test and my own test html file are served up correctly.
(ie http://localhost and http://localhost/test.html respectively)

when trying to launch http://localhost/test.lc, it now fails with a new error:

Code: Select all

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at stam to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
I have tried ghettocottage's suggestions but they didn't make a difference, and neither did Elanor's suggestions...

I'll keep at it (even though i should be working :) ) but would be grateful for more suggestions... does anyone have this running on Catalina in apache?

Re: LC Server (Indy)

Posted: Fri Aug 28, 2020 10:58 pm
by ghettocottage
Bummer.
On my ubuntu servers (which I have set up a few), here is what I do to get livecode-server working (this may or may not be helpful):


put the 64-bit livecode-server into /usr/lib/cgi-bin/ folder then make it executable:

Code: Select all

sudo chmod a+x  /usr/lib/cgi-bin/livecode-server
then enable the mods:

Code: Select all

sudo a2enmod actions
sudo a2enmod rewrite
sudo a2enmod cgi
sudo a2enmod alias
I do virtualhosts on my apache server so I can have multiple websites on one server. A virtualhost file with LC Server scripts on my server looks like this:

Code: Select all

<VirtualHost *:80>	
	ServerAdmin admin@livecode.server.com
	ServerName livecode.server.com


	AddHandler livecode-script .lc
	AddHandler livecode-script .db
        Action livecode-script /cgi-bin/livecode-community-server


	<Directory /var/www/livecode.server.com>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride all
		Order allow,deny
		allow from all
    		DirectoryIndex index.lc
    		DirectoryIndex index.html
    		DirectoryIndex index.php
    		Require all granted
	</Directory>

		<Directory /var/www/livecode.server.com>
			Options Indexes FollowSymLinks MultiViews
			AllowOverride All
			Order allow,deny
			allow from all
		        Require all granted
		</Directory>

		ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
		<Directory "/usr/lib/cgi-bin">
			AllowOverride All
			Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
			Order allow,deny
			Allow from all
		        Require all granted
		</Directory>

	
Include conf-available/serve-cgi-bin.conf
</VirtualHost>


then I restart apache:

sudo service apache2 restart



and livecode works after that.

Re: LC Server (Indy)

Posted: Sat Aug 29, 2020 12:32 pm
by stam
Thanks @ghettocottage, but that's sadly not directly applicable to MacOS default apache install, or at least doesn't work for me... for example the command a2enmod is not recognised...

If anyone has a functional LC server running in cgi mode on apache 2.4 on a relatively modern MacOS, please let me know how you did it...