English Amiga Board


Go Back   English Amiga Board > Support > support.Other

 
 
Thread Tools
Old 11 May 2011, 04:38   #1
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Unhappy [Solved] Help with setting up thttpd and CGI

Dear all!

I want to use my Amiga 1200 + Blizzard 1240T as a Web server. I found thttpd to be a nice and lightweigt Web server. Now, I would like to enhance my site with some CGI scripts but I cannot get thttpd to serve them

Here is my config, thttpd.conf:
host=192.168.0.48
port=80
dir=/T/Web
user=nobody
cgipat=**.cgi
logfile=/T/thttpd.log
pidfile=/T/thttpd.pid

and here is how I run thttpd:
thttpd -C thttpd.conf -D

and in "T:Web/" I have a directory "cgi-bin", which contains the command redirect (valid Amiga executable provided along with thttpd) that I renamed redirect.cgi.

When I browse the URL http://192.168.0.48/cgi-bin/redirect.cgi, my Web browser offers me to download the file redirect.cgi: it is not executed by the Amiga from thttpd... Am I nuts or what? If I omit the directive "cgipat", then thttpd complains that it cannot find redirect.cgi, as it should be. So it seems to me that thttpd finds the directory, finds the file but for some reason does not want to execute it...

Thanks in advance!
Yann
tygre is offline  
Old 26 November 2011, 05:36   #2
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Dear all!

Out of desperation , I decided to compile THTTPd by myself to understand what was going on... and I found some answers!

Quote:
Originally Posted by tygre View Post
Dear all!
Here is my config, thttpd.conf:
host=192.168.0.48
port=80
dir=/T/Web
user=nobody
cgipat=**.cgi
logfile=/T/thttpd.log
pidfile=/T/thttpd.pid
The problem did not come from my config. file, although I could replace "**.cgi" by "/cgi-bin/*.cgi".

Quote:
Originally Posted by tygre View Post
When I browse the URL http://192.168.0.48/cgi-bin/redirect.cgi, my Web browser offers me to download the file redirect.cgi: it is not executed by the Amiga from thttpd... Am I nuts or what? If I omit the directive "cgipat", then thttpd complains that it cannot find redirect.cgi, as it should be. So it seems to me that thttpd finds the directory, finds the file but for some reason does not want to execute it...
The CGI script "redirect.cgi" wasn't served simply because it was not executable! Under "sh" (from the excellent Geek Gadgets), "ls -l" would show the file a being not executable, typically "-rwx------". Using "chmod 755 redirect.cgi", the script is being executed... even though it never returns

I'll keep you posted!
Cheers!
Tygre
tygre is offline  
Old 04 January 2012, 20:10   #3
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Dear all!

I spent sometime on THTTPd and finally found reasons to my problems and some solutions:
  1. Why POST'ed data were truncated in THTTPd v2.21 in an attempt to use THTTPd to run a Wiki on my Amiga.
  2. Why CGI scripts did not work with THTTPd v2.25 in an attempt to call the PHP interpreter as a CGI.
To make a long story short, thanks to lots of help and resources over the Internet , I managed to recompile both THTTPd v2.21 and 2.25, to change the limit of POST'ed data in THTTPd v2.21 (SAPI_POST_BLOCK_SIZE), and to "fork" CGI processes in THTTPd v2.25 (IXEmul and ix_vfork()).



Now, my Wiki should just work as desired! I will post more explanations later...


Cheers!
Tygre
tygre is offline  
Old 21 June 2012, 23:37   #4
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Hi all!

Here are some more explanations about the (several) problems that I met.

First of all, only THTTPd v2.21bP22 has been "officially" adapted to call PHP (v4.2.3). This version of THTTPd is therefore the best to start with for serving Web pages from an Amiga. However, the version available on Aminet had been recompiled "as is" and the size of the blocks of data allowed to be exchanged between THTTPd and PHP was just too small: 4,000 bytes. To change this number, SAPI_POST_BLOCK_SIZE, PHP (and thus THTTPd) must be recompiled.

Second of all, cross-compiling such programs on Windows/Cygwin is a pain for two main reasons: GCC generate sometimes buggy code, as in the case of variadic parameters, which makes it difficult to pinpoint and solve memory problems. Recompiling/porting such programs to the Amiga requires using the IXEmul library, which cannot offer all the support needed to seamlessly recompile UNIX programs for the Amiga, such as fork().

Third, classic Amiga are getting old despite still being young and some memory problems can creep up not from the software side but from the hardware side, due to heat, capacitors... These problems are very, very hard to pinpoint but nothing that a couple of fans and a open case and, eventually, some new capacitors cannot fix...

All in all, after some hours of compiling, debugging, modifying, reverting changes, and crying for help , I was able to recompile a working version of THTTPd v2.21bP22 + PHP v4.2.3 while changing the SAPI_POST_BLOCK_SIZE to 65,536 bytes to allow THTTPd and PHP to happily work together. I tried to document all this effort on a Wiki that is running on top of the very THTTPd that I recompiled. Any question or suggestion are welcome and thank you all for your help!

Cheers!
Tygre

PS. Could a kind moderator mark the title of this thread as "solved"?
tygre is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
SmartFileSystem? [Solved] IRQBreaker support.FS-UAE 2 28 October 2012 19:19
About CGI:IRC, IRC trolls and EAB accounts (again) eLowar project.IRC 9 22 September 2007 10:44
CGi-IRC problem Ian project.IRC 15 25 November 2003 23:07
Question about the CGI IRC Shatterhand project.IRC 4 17 December 2002 20:13

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:15.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06818 seconds with 13 queries