# Perl and php inside rails

**URL:** <https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608>\
**Category:** Rails\
**Created:** [October 20, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608 "2009-10-20T22:51:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 20, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/1 "2009-10-20T22:51:12Z")

</div>

Ok, I know this sounds weird, but I have a client who has some perl and  
php things already written that they want to use. I don’t really know  
much about either of these languages, so I just assumed I could throw  
them in the public directory and post to them through a form by calling  
the script name. That didn’t work. I read a few different posts that I  
need to setup a cgi-bin folder. So, I made the new folder in my railsapp  
root directory, then put the scripts in there. When I put

... this gives my a 404 error. How can I make that form work? Do I need to add a .htaccess into my public folder that does some sort of rewrite or something?

Thanks for the help,

~Jeremy

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 20, 2009, 11:08pm UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/2 "2009-10-20T23:08:41Z")

</div>

On Tue, Oct 20, 2009 at 1:51 PM, Jeremy W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ok, I know this sounds weird, but I have a client who has some perl and  
> php things already written that they want to use. I don’t really know  
> much about either of these languages, so I just assumed I could throw  
> them in the public directory and post to them through a form by calling  
> the script name. That didn’t work. I read a few different posts that I  
> need to setup a cgi-bin folder. So, I made the new folder in my railsapp  
> root directory, then put the scripts in there. When I put
> 
> ... this gives my a 404 error.

? If you’re literally putting that in a directory called “cgi-bin” then  
the  
value for action would be “/cgi-bin/form.pl”.

But you may need to configure cgi-bin completely differently (and  
_outside of_ your rails app) depending on what server you’re using.

If you’re using Apache httpd, reading the comments in httpd.conf is  
probably a good first step 🙂

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 20, 2009, 11:32pm UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/3 "2009-10-20T23:32:11Z")

</div>

Thanks for the response. Yeah, I was putting it in a folder called  
“cgi-bin” that is located inside my application root folder. When I  
would post to it using it  
would just give me a 404.

I decided to drop the perl, and just focus on PHP. I found a similar  
script done in PHP.

[http://www.dtheatre.com/scripts/formmail\_doc.php](http://www.dtheatre.com/scripts/formmail_doc.php)

I have these static html files in my public folder. In these html files,  
they have forms that I need to post to formmail.php.

I just keep getting a 404 saying it doesn’t exist. Any ideas?

Server setup is:  
Slackware  
Apache 1.3  
Mongrel  
php 5.2  
Rails 2.3.2  
Ruby 1.8.7

~Jeremy

Hassan S. wrote:

> On Tue, Oct 20, 2009 at 1:51 PM, Jeremy W.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Ok, I know this sounds weird, but I have a client who has some perl and  
> > php things already written that they want to use. I don’t really know  
> > much about either of these languages, so I just assumed I could throw  
> > them in the public directory and post to them through a form by calling  
> > the script name. That didn’t work. I read a few different posts that I  
> > need to setup a cgi-bin folder. So, I made the new folder in my railsapp  
> > root directory, then put the scripts in there. When I put
> > 
> > ... this gives my a 404 error.
> 
> ? If you’re literally putting that in a directory called “cgi-bin” then  
> the  
> value for action would be “/cgi-bin/form.pl”.
> 
> But you may need to configure cgi-bin completely differently (and  
> _outside of_ your rails app) depending on what server you’re using.
> 
> If you’re using Apache httpd, reading the comments in httpd.conf is  
> probably a good first step 🙂
> 
> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 20, 2009, 11:54pm UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/4 "2009-10-20T23:54:21Z")

</div>

On Tue, Oct 20, 2009 at 2:32 PM, Jeremy W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the response. Yeah, I was putting it in a folder called  
> “cgi-bin” that is located inside my application root folder. When I  
> would post to it using it  
> would just give me a 404.

> I have these static html files in my public folder. In these html files,  
> they have forms that I need to post to formmail.php.
> 
> I just keep getting a 404 saying it doesn’t exist. Any ideas?

> Apache 1.3

Alright, where _exactly_ is formmail.php?

But actually, if it were me – I would bypass a lot of probable grief  
by creating a virtual host, e.g. [scripts.example.com](http://scripts.example.com), just to run the  
PHP/cgi/whatever other stuff independently of your Rails install.

Then set your action=“[http://scripts.example.com/formmail.php](http://scripts.example.com/formmail.php)”,  
tickety boo and bob’s y’r uncle 🙂

## FWIW,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 21, 2009, 12:24am UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/5 "2009-10-21T00:24:48Z")

</div>

On Tue, Oct 20, 2009 at 3:00 PM, Jeremy W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OMG, lol. This whole thing is a huge mess. The actual server  
> administrator doesn’t know how to do anything on it. I had originally  
> suggested doing that, and he goes “I don’t know how, can you do it?”.  
> This is for a place here in vegas, and they have weird rules  
> about how  
> things have to be done. I don’t know how to create a subdomain on their  
> site, and neither do they \>.\<

The _server administrator_ doesn’t know how? Madre de dios.

It’s so trivial. Seriously, look at the comments in httpd.conf. That’s  
enough for most stuff, and if not, the Apache httpd documentation  
is very nice. Read both.

> The formmail.php file is in the public folder. It was suggested by a  
> friend of mine that I create a subfolder like “stupid\_php\_scripts” and  
> then tell mongrel to ignore that folder since everything is being  
> proxied through mongrel. then I would post to  
> “/stupid\_php\_scripts/formmail.php”. The only thing is that I don’t know  
> how to tell mongrel to ignore some fodlers or files.

I don’t know either, but I’d bet it would be easier to configure httpd  
to _not_ proxy `/stupid_php_scripts/*` to mongrel.

I guess all I can say is good luck 🙂

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 21, 2009, 12:00am UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/6 "2009-10-21T00:00:19Z")

</div>

OMG, lol. This whole thing is a huge mess. The actual server  
administrator doesn’t know how to do anything on it. I had originally  
suggested doing that, and he goes “I don’t know how, can you do it?”.  
This is for a place here in vegas, and they have weird rules  
about how  
things have to be done. I don’t know how to create a subdomain on their  
site, and neither do they \>.\<

Thanks for the help though, at least I know _I_ was on the right track  
in the first place.

The formmail.php file is in the public folder. It was suggested by a  
friend of mine that I create a subfolder like “stupid\_php\_scripts” and  
then tell mongrel to ignore that folder since everything is being  
proxied through mongrel. then I would post to  
“/stupid\_php\_scripts/formmail.php”. The only thing is that I don’t know  
how to tell mongrel to ignore some fodlers or files.

~Jeremy

Hassan S. wrote:

> On Tue, Oct 20, 2009 at 2:32 PM, Jeremy W.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Thanks for the response. Yeah, I was putting it in a folder called  
> > “cgi-bin” that is located inside my application root folder. When I  
> > would post to it using it  
> > would just give me a 404.
> 
> > I have these static html files in my public folder. In these html files,  
> > they have forms that I need to post to formmail.php.
> > 
> > I just keep getting a 404 saying it doesn’t exist. Any ideas?
> 
> > Apache 1.3
> 
> Alright, where _exactly_ is formmail.php?
> 
> But actually, if it were me – I would bypass a lot of probable grief  
> by creating a virtual host, e.g. [scripts.example.com](http://scripts.example.com), just to run the  
> PHP/cgi/whatever other stuff independently of your Rails install.
> 
> Then set your action=“[http://scripts.example.com/formmail.php](http://scripts.example.com/formmail.php)”,  
> tickety boo and bob’s y’r uncle 🙂
> 
> ## FWIW,
> 
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [October 21, 2009, 12:39am UTC](https://www.ruby-forum.com/t/perl-and-php-inside-rails/177608/7 "2009-10-21T00:39:32Z")

</div>

Thanks man 🙂
