|
|
|
|
|
|
| Author |
Message |
Jeremy Bowers *nix forums Guru Wannabe
Joined: 23 Feb 2005
Posts: 129
|
Posted: Thu Feb 03, 2005 6:20 pm Post subject:
Re: Apache & Python 500 Error
|
|
|
On Thu, 03 Feb 2005 13:55:13 +0100, Christian wrote:
| Quote: | from mod_python import apache
^
SyntaxError: invalid syntax
----
My test script:
#!/usr/bin/python
print 'Content-Type: text/plain\r'
print '\r'
import os
print os.getcwd()
|
For the quote of the error message, I've taken the liberty of stripping
off the apache-added stuff off the front so you can read it better.
You should now be able to easily see that the error message and your shown
program don't mesh. That error appears to be from an earlier run.
Even so, I can tell you one thing: The error resulted from indenting your
"from mod_python import apache" call that you no longer have. Python uses
whitespace for structure, and just as you must indent the body of loops,
you must *not* extraneously indent other things (line continuations
don't count).
You'll need to post the correct error message after configuring Apache for
CGI as Peter showed, unless of course you figure out the problem. |
|
| Back to top |
|
 |
Peter van Kampen *nix forums beginner
Joined: 03 Feb 2005
Posts: 1
|
Posted: Thu Feb 03, 2005 12:18 pm Post subject:
Re: Apache & Python 500 Error
|
|
|
On 2005-02-02, Christian <stonis@hotmail.com> wrote:
| Quote: | Hello,
i have an apache 1.3 server with python on debian. Python works fine but
the scripts wont´t work.
This easy script i want to do on apache:
#!/usr/bin/python
import os
os.getcwd()
in apache config i have done this:
Directory /var/www/python
AddHandler python-program .py
PythonHandler python
Order allow,deny
Allow from all
#PythonDebug On
/Directory
the script is in this directory /var/www/python
but i get an 500 error everytime, with "every" script
|
You're confusing mod_python and cgi. And you're cgi isn't written
properly...
Try this to enable cgi for python files:
<Directory /var/www/python>
Options +ExecCGI
AddHandler cgi-script py
</Directory>
Don't forget to restart apache.
A proper cgi-file outputs a header with at least the content-type. A
header is followed by an empty line.
#!/usr/bin/env python
import os
print "Content-type: text/html"
print
print os.getcwd()
--
Peter van Kampen
pterk -- at -- datatailors.com |
|
| Back to top |
|
 |
Christian *nix forums beginner
Joined: 11 Mar 2005
Posts: 36
|
Posted: Thu Feb 03, 2005 11:55 am Post subject:
Re: Apache & Python 500 Error
|
|
|
Jeremy Bowers schrieb:
| Quote: | But first, check your apache error log. Then you will know what your error
is, too.
|
Thanks for help, here is my error log:
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: Traceback (most
recent call last):
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 181, in
Dispatch\n module = import_module(module_name, _req)
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 335, in
import_module\n module = imp.load_module(mname, f, p, d)
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: File
"/var/www/python/python.py", line 1
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: from
mod_python import apache
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: ^
[Thu Feb 3 13:52:49 2005] [error] PythonHandler python: SyntaxError:
invalid syntax
----
My test script:
#!/usr/bin/python
print 'Content-Type: text/plain\r'
print '\r'
import os
print os.getcwd()
thanks to Fuzzyman for test script |
|
| Back to top |
|
 |
Jeremy Bowers *nix forums Guru Wannabe
Joined: 23 Feb 2005
Posts: 129
|
Posted: Wed Feb 02, 2005 3:56 pm Post subject:
Re: Apache & Python 500 Error
|
|
|
On Wed, 02 Feb 2005 10:28:46 +0100, Christian wrote:
| Quote: | Hello,
i have an apache 1.3 server with python on debian. Python works fine but
the scripts wont´t work.
|
I know what your problem is.
But first, check your apache error log. Then you will know what your error
is, too.
If you can't fix it after you try to fix the error in the log, or you
don't understand the log entry, post your program and all relevant log
entries. You did good posting your Apache configuration, but we also need
the log entries.
That said, fuzzyman is right, but keep this in mind for future help
requests. |
|
| Back to top |
|
 |
Fuzzyman *nix forums Guru
Joined: 21 Feb 2005
Posts: 406
|
Posted: Wed Feb 02, 2005 12:08 pm Post subject:
Re: Apache & Python 500 Error
|
|
|
What does the error log report ?
It is *possible* that you are getting an error 500 because your are
not emitting valid headers.
Try this instead :
#!/usr/bin/python
print 'Content-Type: text/plain\r'
print '\r'
import os
print os.getcwd()
Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml |
|
| Back to top |
|
 |
Christian *nix forums beginner
Joined: 11 Mar 2005
Posts: 36
|
Posted: Wed Feb 02, 2005 8:28 am Post subject:
Apache & Python 500 Error
|
|
|
Hello,
i have an apache 1.3 server with python on debian. Python works fine but
the scripts wont´t work.
This easy script i want to do on apache:
#!/usr/bin/python
import os
os.getcwd()
in apache config i have done this:
<Directory /var/www/python>
AddHandler python-program .py
PythonHandler python
Order allow,deny
Allow from all
#PythonDebug On
</Directory>
the script is in this directory /var/www/python
but i get an 500 error everytime, with "every" script - why that - i´m
newbie - sorry for that :)
greetings from germany to newsgroup
christian |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 11:29 pm | All times are GMT
|
|
Debt Consolidation | Mobile Phones | Loans | Live mortgage rates | Home Equity Loan
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|