Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache and Python causing me to fall of the wagon.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Fri Feb 11, 2005 11:27 pm    Post subject: Apache and Python causing me to fall of the wagon. Reply with quote

Well I dont' get it. One of my coworkers setup apache on a windows machine, installed ActivePython, and made this awesome python script. Now I came home to get it going on my gentoo server and the thing doesn't work. I can't even get the helloworld.py to go:

Code:
#!/usr/bin/env python

print "Content-type: text/html\n\n"
print "Hello World!"


When I access this file using the url www.mydomain.com/helloworld.py I get a 403 forbidden. I have no clue whats going on here.

Help me Obi-Wan Kenobi your my only hope.
_________________
My Site
Back to top
View user's profile Send private message
justanothergentoofanatic
Guru
Guru


Joined: 29 Feb 2004
Posts: 337

PostPosted: Sat Feb 12, 2005 3:00 am    Post subject: Reply with quote

Hrm...is the script stored in the cgi-bin directory? Is it world readable and executable? Are you able to execute the other sample scripts in cgi-bin?

-Mike
Back to top
View user's profile Send private message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Sat Feb 12, 2005 4:32 am    Post subject: Reply with quote

Well, cgi-bin is in /var/www/localhost/cgi-bin. All my web directories are in /var/www/localhost/htdocs/. All the files are executable and I changed the owners to nobody and apache, neither worked. From what I've gathered people feel mod_python is a nightmare.
_________________
My Site
Back to top
View user's profile Send private message
j-m
Retired Dev
Retired Dev


Joined: 31 Oct 2004
Posts: 975

PostPosted: Sat Feb 12, 2005 9:53 am    Post subject: Reply with quote

Shiner_Man wrote:
Well, cgi-bin is in /var/www/localhost/cgi-bin. All my web directories are in /var/www/localhost/htdocs/. All the files are executable and I changed the owners to nobody and apache, neither worked. From what I've gathered people feel mod_python is a nightmare.


mod_python worked for me pretty much out of the box - for hello world :lol:

I did not try anything else yet, but these two lines should do for a basic test.

Code:

AddHandler mod_python .py
PythonHandler test


Code:

$ less test.py

from mod_python import apache

def handler(req):
        req.write("Hello World!")
        return apache.OK
Back to top
View user's profile Send private message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Sat Feb 12, 2005 2:16 pm    Post subject: Reply with quote

This confuses me. So everytime you write a new .py application you have to add a seperate handler for it in apache's configuration files?
_________________
My Site
Back to top
View user's profile Send private message
xy77
Tux's lil' helper
Tux's lil' helper


Joined: 22 Aug 2003
Posts: 85

PostPosted: Sun Feb 27, 2005 8:30 am    Post subject: Reply with quote

Shiner_Man wrote:
Well, cgi-bin is in /var/www/localhost/cgi-bin. All my web directories are in /var/www/localhost/htdocs/. All the files are executable and I changed the owners to nobody and apache, neither worked. From what I've gathered people feel mod_python is a nightmare.


If you emerged mod_python, you should be able to put a script test.cgi

Code:

#!/usr/bin/python

print "Content-type: text/html\n\n"
print "Hello World!"



in /var/www/localhost/cgi-bin/ , change permissions to executable by all (or set group apache and permission to g+x) and you should be able to view it by calling http://localhost/cgi-bin/test.cgi from your browser.

Alternatively try /var/www/localhost/htdocs/cgi-bin - one never knows. :-)

If this works, you still can try to figure out, how to make .py extensions work.

Personally I put it in ~/public_html/cgi-bin/ so my web stuff gets backuped, when I backup my home dir.

- xy77
Back to top
View user's profile Send private message
iulica
n00b
n00b


Joined: 28 Jul 2004
Posts: 34

PostPosted: Mon Mar 28, 2005 12:29 pm    Post subject: Reply with quote

Shiner_Man wrote:
This confuses me. So everytime you write a new .py application you have to add a seperate handler for it in apache's configuration files?


I want to know this too. Can anyone answer ? I find it also confusing.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum