LC server install on a shared host without root

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

LC server install on a shared host without root

Post by AxWald » Sun May 10, 2020 1:27 pm

Hi all,

I finally did it - after untold frustrating attempts I finally got my first:
Hello World! 12:01 PM
from an LC server. My problem was that I'm on a shared server (allinkl.com), and have no access to the apache configuration & only limited access to the file system, so most of the advises given regarding the installation don't match.

For the benefit of other members of our community I decided to document what I've done, step by step. I'm using "Filezilla" as my FTP program, and "Putty" for SSL (You don't really need SSL, but it makes things easier). I assume that both are installed & configured to access our server.
  1. At first, we determine the type of server we're running on, using Putty:

    Code: Select all

    x$ 	uname -srm
    	Linux 4.4.0-177-generic x86_64
    
    This confirms my suspicion that we're on a 64bit Linux. So we need a Linux 64-bit LC server. (Guess any provider worth its salt will run x86-64 by now ... And "x$" is the long, cryptic linux start of the command line, shortened.)
    .
  2. Second, we grab our server from here.
    Careful, the "last stable" 9.5.1-64 threw "Segmentation faults" reliably, whereas the 8.1-64 runs flawlessly.
    .
  3. Now we use Filezilla to create a directory "cgi-bin" in the base directory of the desired domain: "/" shows all of our webspace, "/domain.com" is where our domain specific data lives.
    So what we create is "/domain.com/cgi-bin", and we change the access to "755".
    .
  4. Assuming we have SSH, we copy the downloaded, zipped LC server file via FileZilla into our "cgi-bin" & run "unzip [servername.zip]" via Putty. This assures we get unaltered files.
    If we don't have SSH, we unzip the server locally & make sure to transfer it in "binary mode". And hope it works ...
    .
  5. We need to "chmod" (change acces privileges) our server application now to "755" via Filezilla or SSH, and we may rename it - I use "lcserver" for easy access. What we have now should look like this (I've renamed some things ...):
    ftp.png
    Filezilla sees our web space like this
    You'll see a file "test.lc" in cgi-bin that is explained below, and 2 zipped server installations - those we can delete.
    .
  6. To test our server we need a simple command file, a very basic one is:

    Code: Select all

    <?lc
    put "Hello World!" && the time
    ?>
    Put this one into your cgi-bin as "test.lc", and make sure you have unix line endings (LF only)!
    .
  7. If we have SSH, we can test it now:

    Code: Select all

    x$ 			cd domain.com/cgi-bin
    x/domain.com/cgi-bin$ 	./lcserver ./test.lc
    			Hello World! 1:34 PM
    wOOt! :)
    .
  8. If not, or if we want to call it as CGI (means using it via POST/ our web browser), we need some lines in the .htaccess file of our domain ("/domain.com/.htaccess"). If not (it exists), create it. If it exists, add these lines:

    Code: Select all

    Options +ExecCGI
    AddHandler livecode-script .lc
    Action livecode-script /cgi-bin/lcserver
    
    (Big "THANK YOU!" to Thierry!)
    If there are already lines like this, you may want to ask someone that's better in web server things than me ...
    Again, make sure you have unix line endings (LF only)!
    .
  9. Last test: We go to our domain in the browser: ("https://domain.com/cgi-bin/test.lc") and get:
    Hello World! 1:51 PM
    Bingo! Done.
Now we have a LC server running that we can call via command line (to do server tasks) or that we can use to provide data to us, via CGI. Be aware, this is just the beginning, now our real work starts:
  • Making sure the installation is safe & will not get captured easily.
  • Finding out which LC server version to use actually - which one is fastest & least buggy?
  • Writing tons of .lc scripts to actually work with it :)
I hope this will help some poor soul (it took me a long time & countless tries to come this far), and that someone will correct my mistakes that I've made unavoidably. I'm especially interested in advice regarding security, and the best suited server version. (Nobody ever tried to compile 6.7.10 for Linux 64-bit?)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: LC server install on a shared host without root

Post by bangkok » Sun May 10, 2020 2:39 pm

allinkl.com costs 4,95 euros per month, right ?

No need to increase your blood pressure.

Have a look at :
https://www.hostm.com

3,95 USD per month.

And... LC Server... in standard. Pre-installed.

Works like a charm. Nothing to do. :)

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: LC server install on a shared host without root

Post by AxWald » Sun May 10, 2020 3:11 pm

Hi,

well, it's not my server - it's one of my customers.
And we'll stay with allInkl - these are production systems, and a lot of ppl are depending on it to earn their bread. This provider so far has proven as:
  • Highly reliable (nearly 100% uptime during the recent years)
  • Very quick support response times, 24/7/365
  • Quick & competent help when required
  • Able to fulfill the legal requirements for businesses (data center location, ADV, DSGVO ...)
You don't change such easily. A few bucks/ month doesn't make this much of a difference.

And, after all it wasn't this complicated, right? Better documentation could have helped a lot - therefore I wrote my sermon above :)

Have fun!

Disclaimer: I'm only customer at AllInkl, don't even have affiliate. And I know next to nothing about hostM.
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC server install on a shared host without root

Post by FourthWorld » Sun May 10, 2020 5:16 pm

Thanks for posting that, AxWald.

The steps you outlined are hopefully similar to the ones posted here - if you find anything here that doesn't work on your shared host please consider filling an enhancement request for that documentation so it can be used for more server configurations:
http://lessons.livecode.com/m/4070/l/36 ... a-htaccess

HostM seems a good service, but to be soberly candid, if installing any program to run as a CGI under Apache is prohibitively difficult, that may be an indicator that the user has not yet acquired the background on how Apache works to be able to use it safely and effectively.

I can appreciate the desire for just-get-it-done, but server work takes on a level of responsibility far greater than making apps for local use only. It's not just that user data must be protected, but even the server's resources too.

When we apply how-tos without also acquiring an understanding of the underlying "why" behind those steps, we not only limit our own abilities when we encounter a slightly different server set-up, but we also miss out on knowing how Apache works, knowledge that pays for its acquisition cost many times over as we move forward with client-server apps over the years ahead.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Wed Feb 10, 2021 5:50 am

hI @Axwald,

I would be interested to know if all you did was just unzip the Server.zip file in a folder of your server...maybe apply some Chmod.. "and voila" !
iWould it process any script just with that ?
>>> this is what I was doing today, uploaded, unziped and some chmod.. .but did not run any test file still.
..(will test your sample tonite :mrgreen: )

somehow - reading at the PDF server doc... I figured out that I would have to run a complete " Livecode-server INSTALL -IU " from the command line in order to get it all installed correctly :?: :!:
(copying how it looks on a PC.. .revrun/components/blabla )... but is that even necessary ???

Thanks for any help, your descriptive steps are quite interesting anyway !!!
Thanks for any experience return.
:wink:
Last edited by liveme on Wed Feb 10, 2021 7:17 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC server install on a shared host without root

Post by FourthWorld » Wed Feb 10, 2021 7:23 am

The LiveCode Lessons series is your friend:

https://lessons.livecode.com/m/4070/l/3 ... a-htaccess
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Sun Feb 14, 2021 3:42 am

Hi AxWald :wink: ,
Thanks for the described steps.
It's "half working" for me... :P (using Stable 9.6.1)* see at the bottom why this one.

I'm on a shared host too and as for the terminal test result,
I still can't get lcserver to DISPLAY some live code such as a hello.lc
and .lc script execution/loading wil not interpret any livecode code...only linux os code.

In terminal
So the hello.lc script MIGHT execute but silently in the background - seems to me :
- I just get a new empty line.
- no error message is displayed.

if running a dir.lc script with just the "ls" command inside.
dir.lc works, displaying the full linux directory content in the terminal.

those command below wont find the file :
www.mydomain.com/hello.lc
www.mydomain.com/cgi-bin/hello.lc
returns, The requested URL was not found on this server.

I'm thinking of moving the cgi-bin folder upper in the path maybe public-html/cgi-bin...

I have added and modified an htaccess file according to my lcserver renamed file...Still it cant find it it seems.
copied the htaccess within the cgi-bin folder..and copied upper...


Note as for 8.1.xxx 64 linux zip, they do not seem to include any Driver or External folders !??
just the livecode server.
...whereas the 8.1-64 runs flawlessly.
Any suggestions could help.
*else my hosting could be the major limiter. :roll:
Do you know wich exact Stable ver. number has it all ? :idea:

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Sun Feb 14, 2021 4:28 am

... Oh No... LC scripts are finaly working in the Terminal, what did I do ? :D

just re-downloaded and re-uploaded the indy server 9_6_1-Linux-x86_64 file, maybe that's all it needed !
:idea:

Code: Select all

  Operating System: CloudLinux 7.9 (Boris Yegorov)
       CPE OS Name: cpe:/o:cloudlinux:cloudlinux:7.9:GA:server
            Kernel: Linux 3.10.0-962.3.2.lve1.5.42.el7.x86_64
      Architecture: x86-64
ps : Can some Team members explain when Driver or External folders are usefull for ?
thanks

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: LC server install on a shared host without root

Post by AxWald » Sun Feb 14, 2021 1:12 pm

Hi,

just a few things:

- I have both my "cgi-bin" folder & my ".htaccess" in "myDomain.com/".

- The "LiveCodeCommunityServer-9_5_1-Linux-x86_64.zip" server threw "Segmentation faults" reliably, so I tried another one - "LiveCodeCommunityServer-8_1_0-Linux-x86_64.zip" worked at first try.
Due to other obligations I haven't been able to do much with LC server since; I'm still planning to find out which of the newer "stables" is actually the "least unstable" - unfortunately RunRev seems to have become quite "agile" now, releasing no "stables" in the old sense anymore at all. Instead they seem to use the euphemism "stable" for what once would have been a "public beta" ...

- Above 8.1 server came with both "drivers" & "externals".

- The files in "drivers" are database connectors - delete those you don't need. The files in "externals" are extensions for database, ZIP & XML. You might not need them all.

- When lc scripts are working in the terminal, you're nearly done. All that's left is to persuade your web server to redirect calls for lc scripts to the LC server - that's what I did via .htaccess above.

- You're talking about "Livecode-server INSTALL -IU" above. That's not needed, the server comes as a ZIP, not with an installer. It seems to come from the PDF accompanying the server package - but this are just the vanilla release notes, wrongly named.

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Sun Feb 14, 2021 9:49 pm

Thanks axwald,

Ok, I'll will check to make sure that htaccess remains in the cgi-bin (had made a copy in public folder during trial)

interesting...my download of 8.1 did not extract driver folders....will test again when I have some time.

Segmentation faults :
Could you share some Lc code sample that did produced the "segmentation faults" ?
Were you testing some large DB content upload or heavy calculation in server memory ?
..anyway,..whatever might produce this error could help.
I will test code for both Postgres and Mysql content crud.

My task from today on... is finding ways to Post/Get data from Desktop to DB using the "new" LC server way.
I did succeed that already using the Mysqli SQL way to upload data...only need to find how to download it back.

Thanks for the points about Driver/external.
nice end of week ! 8)

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: LC server install on a shared host without root

Post by AxWald » Mon Feb 15, 2021 3:03 pm

Hi,
liveme wrote:
Sun Feb 14, 2021 9:49 pm
Ok, I'll will check to make sure that htaccess remains in the cgi-bin (had made a copy in public folder during trial)
In my example both cgi-bin & .htaccess are at the same level, @ domain root!
liveme wrote:
Sun Feb 14, 2021 9:49 pm
interesting...my download of 8.1 did not extract driver folders....will test again when I have some time.
Hmm. Every server I tried unzipped correctly (I upload the [server.zip] & unzip in place, via SSH "unzip server.zip").
liveme wrote:
Sun Feb 14, 2021 9:49 pm
Segmentation faults :
Could you share some Lc code sample that did produced the "segmentation faults" ?
Just calling the server from SSH, with my example script:
[9.6.1 LC Server]$ ./lcserver ./test.lc
Segmentation fault

[8.1 LC Server]$ ./lcserver ./test.lc
Hello World! 2:18 PM
As you see, I now tried the last "stable", same error. 8.1 works, if treated exactly the same. No idea why :/

liveme wrote:
Sun Feb 14, 2021 9:49 pm
My task from today on... is finding ways to Post/Get data from Desktop to DB using the "new" LC server way.
My simplistic way to handle this would be to base64encode my parameters & send them to the appropriate LC script via:

Code: Select all

https://myDomain.com/cgi-bin/upperme.lc?data=YXh3YWxkQGZvcnVtcy5saXZlY29kZS5jb20=
The "upperme.lc" script would then handle it & respond with a result:

Code: Select all

<?lc
put upper(base64decode($_GET["data"]))
?>
For sure this could be a database query as well.

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Mon Feb 15, 2021 10:36 pm

this would be to base64encode
Hm, yeah, good idea, I am so focused on php/msqli .
...via SSH "unzip server.zip").
yep, could be the reason why its different I unzipped it localy once or twice...though, I m on linux so dont see why it would make a diference, anyway.
Just calling the server from SSH,
okay, I havent made any other call than for a hello.lc or givemetime.lc to 9.6.1, very simple codes each time.
All called were made using an SSH Terminal connected to the host online...so not originated from my PC.
results were as expected : "hello world", time is blabla...so no segmentation fault in this testing config. with 9.6.1.

Snowflake ssh terminal in cgi-bin:

Code: Select all

 ./liveserve ./hello.lc
>> Server Date : 2/15/21 Server Time : 10:26 PM
<?lc
put "Server Date : " &&the date
put "Server Time : " &&the time
?>
Question : Do any of your LC script execute if called from the Browser Url field or it would never reply if someone tries to execute them in that way ?
>> www.mydomain.com/hello.lc

thanks

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Mon Feb 15, 2021 11:04 pm

on my server :
I created both the cgi-bin & php folders at these levels :
*might not be the most apropriate places...

filezila displays it like this :
Image
Attachments
folders tree.png
folders tree.png (10.72 KiB) Viewed 8254 times

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: LC server install on a shared host without root

Post by liveme » Tue Feb 16, 2021 12:04 am

right below :
Step 1 - Install the desired version (and edition) of the LiveCode Server
...this page is displaying an install of the cgi-bin folder inside the public_html folder (?!)
*
could that be safe ?
:roll:

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC server install on a shared host without root

Post by FourthWorld » Tue Feb 16, 2021 3:48 am

liveme wrote:
Tue Feb 16, 2021 12:04 am
...this page is displaying an install of the cgi-bin folder inside the public_html folder (?!)
*
could that be safe ?
:roll:
Putting cgi-bin inside the web root is common with shared hosting. I prefer it in my home folder one up from the web root, but some hosts may not allow that.

Either way, with the engine set to permissions of 755 it'll execute but for anyone but you it can be neither read from nor written to. So for scenarios where shared hosting is a good fit it's reasonably safe.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “CGIs and the Server”