# $$$$ To configure mod_python; mod_php; mod_ruby

## netjunkie

Hi Gang,

I am prepared to pay money to have mod_php, mod_python, mod_ruby configured and working perfectly.

Payment by paypal.

I have been able to get mod_php working but it screws up on trying to configure mod_python.

----------

## nixnut

Moved from Installing Gentoo to Networking & Security.

Network stuff, so moved here.

----------

## csbrown

can you be more specific about "screws up"?  are you using emerge/ebuild(s) for these?  are you using apache, if so which version?  how was it installed/built/configured?

i'm sure that someone will take you up on your offer, but you might be able to get this working easily without paying...

----------

## netjunkie

the following is installed:

net-www/apache-2.0.54-r31

dev-python/mod_python-3.1.4-r1 

dev-ruby/mod_ruby-1.2.4 

dev-php/mod_php-4.4.0-r9 

my http directory is /var/www/localhost/htdocs

who ever is interested in the doing this for cash, please notify me as soon as possible.

the following is my httpd.conf

 *Quote:*   

> 
> 
> #
> 
> #  This is a modification of the default Apache 2 configuration
> ...

 

16_mod_python.conf

 *Quote:*   

> 
> 
> <IfDefine PYTHON>
> 
>   <IfModule !mod_python.c>
> ...

 

70_mod_php.conf

 *Quote:*   

> 
> 
> # vim: ft=apache sw=4 ts=4
> 
> <IfDefine PHP4>
> ...

 

20_mod_ruby.conf

 *Quote:*   

> 
> 
> <IfDefine RUBY>
> 
>   <IfModule !mod_ruby.c>
> ...

 

----------

## csbrown

Can you detail the nature of the problem that you are having?  What doesn't work?

----------

## netjunkie

When i try to connect to any .py file on the webserver, my browser offers it for download.

----------

## netjunkie

The following is a copy of my config:

I do not have any config details for python directly in my httpd.conf, all configs are in the file below.

16_mod_python.conf:

 *Quote:*   

> 
> 
> <IfDefine PYTHON>
> 
>   <IfModule !mod_python.c>
> ...

 

----------

## kashani

Have you added "-D PYTHON -D RUBY" etc to /etc/conf.d/apache That's the usual mistake.

If that is the case does apache2ctl configtest return anything interesting? Or is there anything interesting in the log files?

kashani

----------

## netjunkie

OK guys, finally I have had part success. 

The config below has finally worked. 

16_mod_python.conf

```

<IfDefine PYTHON>

  <IfModule !mod_python.c>

    LoadModule python_module    modules/mod_python.so

  </IfModule>

</IfDefine>

<IfModule mod_python.c>

<Directory /var/www/localhost/htdocs>

    SetHandler python-program

    AddHandler mod_python .py

    

    PythonHandler mod_python.publisher

    PythonDebug On

</Directory>

</IfModule>

```

The default sample that comes with gentoo does not work, in that the "location" directive does not seem to be recognised, as soon as you use Directory, as listed above it works right away.

Who ever is responsible for the mod_python ebuild needs to make this change in the default package.

----------

## netjunkie

Hi,

I do have the -D PYTHON and -D RUBY.

my mod_php is working perfectly now, and mod_python is only partly working. 

I have managed to get it to execute the following:

index.py

```

def index(req):

   return "we are in index()"

def hello(req):

   return "we are in hello()"

```

but when i try to run the following sample:

form.html

```

<html>

      Please provide feedback below:

  <p>

  <form action="form.py/email" method="POST">

      Name:    <input type="text" name="name"><br>

      Email:   <input type="text" name="email"><br>

      Comment: <textarea name="comment" rows=4 cols=20></textarea><br>

      <input type="submit">

  </form>

</html>

```

form.py

```

import smtplib

WEBMASTER = "webmaster@localhost"   # webmaster e-mail

SMTP_SERVER = "localhost" # your SMTP server

def email(req, name, email, comment):

    # make sure the user provided all the parameters

    if not (name and email and comment):

        return "A required parameter is missing, \

               please go back and correct the error"

    # create the message text

    msg = """\

From: %s

Subject: feedback

To: %s

I have the following comment:

%s

Thank You,

%s

""" % (email, WEBMASTER, comment, name)

    # send it out

    conn = smtplib.SMTP(SMTP_SERVER)

    conn.sendmail(email, [WEBMASTER], msg)

    conn.quit()

    # provide feedback to the user

    s = """\

<html>

Dear %s,<br>

Thank You for your kind comments, we

will get back to you shortly.

</html>""" % name

    return s

```

This example does not work and I get the following error.

 *Quote:*   

> 
> 
> Not Found
> 
> The requested URL /dev/pytest/form.html was not found on this server.
> ...

 

but if i point brower to /dev/pytest/

modpython responds stating im in that directory.

So what config do i need to use so that I can run both PythonHandler mod_python.publisher and normal access to .py files?

----------

## csbrown

First figure out why Apache can't serve/find/access form.html...

 *Quote:*   

> 
> 
> Not Found
> 
> The requested URL /dev/pytest/form.html was not found on this server.
> ...

 

For one thing, I don't see a DocumentRoot directive anywhere in your httpd.conf

----------

