View previous topic :: View next topic |
Author |
Message |
Shiner_Man Apprentice
Joined: 09 Mar 2004 Posts: 180
|
Posted: Fri Feb 11, 2005 11:27 pm Post subject: Apache and Python causing me to fall of the wagon. |
|
|
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 |
|
|
justanothergentoofanatic Guru
Joined: 29 Feb 2004 Posts: 337
|
Posted: Sat Feb 12, 2005 3:00 am Post subject: |
|
|
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 |
|
|
Shiner_Man Apprentice
Joined: 09 Mar 2004 Posts: 180
|
Posted: Sat Feb 12, 2005 4:32 am Post subject: |
|
|
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 |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Sat Feb 12, 2005 9:53 am Post subject: |
|
|
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
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 |
|
|
Shiner_Man Apprentice
Joined: 09 Mar 2004 Posts: 180
|
Posted: Sat Feb 12, 2005 2:16 pm Post subject: |
|
|
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 |
|
|
xy77 Tux's lil' helper
Joined: 22 Aug 2003 Posts: 85
|
Posted: Sun Feb 27, 2005 8:30 am Post subject: |
|
|
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 |
|
|
iulica n00b
Joined: 28 Jul 2004 Posts: 34
|
Posted: Mon Mar 28, 2005 12:29 pm Post subject: |
|
|
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 |
|
|
|