Could some expert help to set up Rev CGI (Linux Host)?

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Could some expert help to set up Rev CGI (Linux Host)?

Post by alex298 » Tue Apr 01, 2008 5:49 am

Hi,

I tried to set up a Rev CGI Environment in my hosting account about 1.5 years ago, but failed. Now I changed the hosting (linux hosting) and would like to try again. I read and followed through the steps provided in many documents. However I still cannot set up the CGI enviroment after trying many times.

Could some experts here set up for me? I can provide my hosting login information.

P.S.
1. I already uploaded the linux Revolution-2.5.1 engine to the cgi-bin directory.
2. I also CHMOD the cgi-bin directory to 755
3. I also uploaded a test file (test.cgi) to cgi-bin directory and CHMOD to 755

Thanks and best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Tue Apr 01, 2008 1:43 pm

When you call the cgi, what error do you get in your error log on the server?

What's the code you try (if it's long, then try something shorter)?

did you chmod the engine itself?

what's the line endings in your test cgi?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Tue Apr 01, 2008 2:17 pm

Hi BvG,

Long time no see:)

## When you call the cgi, what error do you get in your error log on the server?

The most common cgi error for beginner - Internal Server Error

## What's the code you try (if it's long, then try something shorter)?

To avoid any unnecessary error, I only use:

#!revolution

## did you chmod the engine itself?

I only CHMOD the cgi-bin directory and the cgi script (test.cgi) to 755. Which files do I also need to CHMOD?

## what's the line endings in your test cgi?

I used Windows to wrtite the cgi script. I used ASII mode to FTP transfer, so the text should be in unix mode. Actually I also read the post of setting up cgi about this problem. The post only said he removed the line ending and the problem solved. I have no any idea how to remove the line ending in windows note pad or other text editor.

Thanks and best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Tue Apr 01, 2008 4:00 pm

alex298 wrote:## When you call the cgi, what error do you get in your error log on the server?

The most common cgi error for beginner - Internal Server Error
I wasn't asking what your browser shows you, I was asking about the error log of your server. If you use some webhosting service, their web interface most likely has an entry to look at error logs. If you have a dedicated server it is most likely found in /var/log/apache or /var/log/httpd.
alex298 wrote:## What's the code you try (if it's long, then try something shorter)?

To avoid any unnecessary error, I only use:

#!revolution
This would always fail. I suggest you try this as a minimal cgi (where the rev engine is named "revolution":

Code: Select all

#!revolution

on startup
  put "Hello, I'm a cgi!" into buffer
  put "Content-Type: text/plain" & cr
  put "Content-Length:" && the length of buffer & cr & cr
  put buffer
end startup
alex298 wrote:## did you chmod the engine itself?

I only CHMOD the cgi-bin directory and the cgi script (test.cgi) to 755. Which files do I also need to CHMOD?
You need to chmod the cgi file, and the engine, the directory only if you want to use stacks in the cgi-bin folder directly.
alex298 wrote:## what's the line endings in your test cgi?

I used Windows to wrtite the cgi script. I used ASII mode to FTP transfer, so the text should be in unix mode. Actually I also read the post of setting up cgi about this problem. The post only said he removed the line ending and the problem solved. I have no any idea how to remove the line ending in windows note pad or other text editor.
The line endings are what delimits the lines in your cgi. If you remove line endings, you would have everything on one line, which would not work at all, so I'd say no one ever suggested that.

Line endings on windows are "cr"&"lf", on unix it's "lf", and on mac os it's "cr". Note that within rev, return, cr and lf are synonyms, which can be confusing. If you want your cgi to run on linux, you need to make sure that the last char of all lines in your file is a linefeed. to do this you could use rev. The following code will automatically change all line endings in a file from the system format (on windows that's carriage return & linefeed), to the unix form (only linefeeds):

Code: Select all

on mouseUp
  answer file "a cgi text file"
  if it = "" or the result <> "" then
    exit mouseUp
  else
    put it into thePath
  end if
  put url ("file:" & thePath) into theData
  put theData into url ("binfile:" & thePath)
end mouseUp
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Wed Apr 02, 2008 4:12 am

Hi BvG,

I used your script and change all line endings in the test file. However the problem still the same.

The error log is also a common error of CGI:

Premature end of script headers: /home/plygcom/public_html/cgi-bin/test2.cgi

It seems to fail to set a content type before printing the output code. I know how to solve this problem in VB, Perl and PHP. However I am a newbie in RR's CGI.

P.S.
I will only use stacks in the cgi-bin folder directly.

Thanks and best regards
Alex
Nice to meet all of you.

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Wed Apr 02, 2008 4:14 pm

Hi,

I just learnt from other documents that the following libraries are also required in Apache server:

libXext.so.6
libX11.so.6
libm.so.6
libc.so.6
ld-linux.so.2

I also installed the above libraries in my dedicated server. However the problem is still the same:

Premature end of script headers: /home/plygcom/public_html/cgi-bin/test.cgi

Best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Wed Apr 02, 2008 11:09 pm

Premature end of script headers just means that the cgi is not recognised as cgi at all. Make sure to set up the cgi stuff like this:

1. Put the revolution engine into the cgi-bin directory, name it "revolution"
2. Put the script (as suggested above) into the same directory
3. Change all the line endings to lf
4. Chmod the script as well as the engine to 755

Report any errors in the log file of your http server.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » Thu Apr 03, 2008 12:50 am

If you have a dedicated server, you could put the revolution runtimes in /usr/local and change the ownership to root so they work for all users.

I found I didnt need any of the extra modules, it was just the permissions and ownerships of the cgi file, and the runtime that I needed to get right.

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Thu Apr 03, 2008 9:16 am

Hi all,

Thanks for your kind assistance.

##Put the revolution engine into the cgi-bin directory, name it "revolution"

Actually I tried before. I did it again.

## Put the script (as suggested above) into the same directory

I always do it that way.

## Change all the line endings to lf

I used your RR script to do that.

## Chmod the script as well as the engine to 755

I also CHMOD the revolution.x86 to 755. For scripts I always CHMOD to 755 same as Perl scripts.

It is still not working. The error is still:
Premature end of script headers:

Any other possible reasons?

Thanks and best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Thu Apr 03, 2008 10:49 am

alex298 wrote:## Chmod the script as well as the engine to 755

I also CHMOD the revolution.x86 to 755. For scripts I always CHMOD to 755 same as Perl scripts.
This can't work. Your script (respective mine) requests an engine named "revolution". Thats what the first line in the script means. If your engine is named "revolution.x86", then obviously the script can't find the engine, and won't run at all. Make sure the engine and the reference in the first line are the same.

your cgi-bin:
revolution 755
test.cgi 755

first line in test.cgi:
#!revolution
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Thu Apr 03, 2008 1:56 pm

Dear BvG,

## Make sure the engine and the reference in the first line are the same.

Oh.... yes. How come I overlook this point?

You are really really very helpful! Are you still living in Switzerland? I will buy you a drink when I come to Switzerland :D Then on to way to Germany to have beer and sausages with Klaus and Malte :D :D

Best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Thu Apr 03, 2008 2:46 pm

I hope it works now for you?

Yes in zurich,switzerland
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Thu Apr 03, 2008 3:02 pm

Dear BvG,

Yes, it works now.

By the way, is there any time limit for the revolution CGI Engine? In other words, can I use the revolution CGI Engine freely without any limitation?

Best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Thu Apr 03, 2008 5:28 pm

The rev engine has always been free to use as cgi.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply

Return to “CGIs and the Server”