cancel
Showing results for 
Search instead for 
Did you mean: 

Perl cgi outside of cgi-bin on ccgi server?

WNewall
Dabbler
Posts: 20
Registered: ‎29-10-2008

Perl cgi outside of cgi-bin on ccgi server?

Is it possible to have perl scripts outside of the cgi-bin folder on the ccgi server?
i.e. something like: http://ccgi.xx.force9.co.uk/yy/zz.pl
where 'yy' is not cgi-bin (and not below cgi-bin).
I've tried various settings in the .htaccess file, but I can't get it to work. Is the ccgi server setup so that perl cgi can only be inside or below the cgi-bin folder?
Thanks,
Woll
9 REPLIES 9
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Perl cgi outside of cgi-bin on ccgi server?

As you've hinted there, perl CGI will only work in the cgi-bin directory, this is how the servers have been configured. You can however use mod_rewrite to make it look as though it's not in cgi-bin, e.g. to make your example work, assuming zz.pl is actually in /cgi-bin (relative to your homedir) you can put the following in a file called .htaccess in your homedir:
RewriteEngine On
RewriteRule yy/zz.pl /cgi-bin/zz.pl
WNewall
Dabbler
Posts: 20
Registered: ‎29-10-2008

Re: Perl cgi outside of cgi-bin on ccgi server?

Hmm, thanks for that Ben.
What I am actually trying to do is to create a mirror (on the ccgi server) of my live site for testing purposes, which I think means that your suggestion wouldn't work. I will start another thread on that subject, to keep things neat.
Woll
WNewall
Dabbler
Posts: 20
Registered: ‎29-10-2008

Re: Perl cgi outside of cgi-bin on ccgi server?

Ben - Am I correct in thinking that your suggestion would NOT work if the path to be matched starts with '/cgi-bin' (because the server executes all /cgi-bin paths directly thereby ignoring any ReWrite rules)?
e.g. this would not work:
RewriteEngine On
RewriteRule /cgi-bin/zz.pl /cgi-bin/test_site/zz.pl

Thanks,
Woll
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Perl cgi outside of cgi-bin on ccgi server?

I've just had a look at the config and indeed it does take over the /cgi-bin, pointing it to the wrapper that we use to run it as your user.
zubel
Community Veteran
Posts: 3,789
Thanks: 1
Registered: ‎08-06-2007

Re: Perl cgi outside of cgi-bin on ccgi server?

couldn't you just use:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteRule ^/([a-z/.]+)$ cgi-bin/$1
and place your entire website structure in the /cgi-bin folder/
if my theory is right (and I havent tested it) you should then just be able to access:  http://ccgi.xxx.plus.com/yyy/zzz.pl ; and it would redirect (internally) to: http://ccgi.xxx.plus.com/cgi-bin/yyy/zzz.pl
It would work for an entire structure - unless someone went directly to the cgi-bin/ folder (that's what the cautionary Rewritecond does)
?
B.
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Perl cgi outside of cgi-bin on ccgi server?

Quote from: Barry
It would work for an entire structure - unless someone went directly to the cgi-bin/ folder

I might have misunderstood but I think this is the OP's issue.
zubel
Community Veteran
Posts: 3,789
Thanks: 1
Registered: ‎08-06-2007

Re: Perl cgi outside of cgi-bin on ccgi server?

ahaa, so there is an existing site in the cgi-bin/ folder?

B.
WNewall
Dabbler
Posts: 20
Registered: ‎29-10-2008

Re: Perl cgi outside of cgi-bin on ccgi server?

Sorry, I was trying to keep it simple, so maybe I didn't explain enough!
It's related to trying to create a test version of a live site, so updates can be checked on the Force9 server before they go live (I posted a separate thread on that).
So, the live site has things in cgi-bin and an index.html in the root folder and the perl scripts are accessed from the html pages using URLs like '/cgi-bin/zz.pl'. The most natural way to create the test version would be to create a 'test_site' folder at the top level and reproduce the same hierarchy as the live site below that folder - with no changes to the source/html - and have a ReWrite to redirect the test site domain to the 'test_site' folder. However, that wont work because (as Ben replied) you can't have perl scripts outside of cgi-bin.
To get round that, you could have the test site (or both sites as suggested) below /cgi-bin, but that also wouldn't work, because the server setup ignores ReWrite rules if the URL starts with '/cgi-bin' (I guess something to do with the way the ScriptsAlias directive works), so the URLs in the source like '/cgi-bin' wont get redirected and will end up running the scripts in the live site instead of the scripts in the test site!
At the moment, I am thinking that the only way to do it would be to create the test site by uploading the new version of the site to the server and then actually editing the URLs in all the files (using an automated script!), so that the perl scripts are called using URLs like '/cgi-bin/test_site/zz.pl', instead of directly inside '/cgi-bin'.
Thanks for the input.
Woll
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Perl cgi outside of cgi-bin on ccgi server?

Edit: deleted obsolete
Gabe