Configuraion to run pyhton script on ubuntu 12.04
Jaiky
jaiprakashsingh213 at gmail.com
Sun Jul 28 12:19:08 EDT 2013
Sir i already tried this "Alias" concept
I did the following steps
===============================================================================
Step 1:
added
"ScriptAlias /cgi-bin/ /var/www/cgi-bin/"
in /etc/apache2/sites-available/default
============================================================================
step 2:-
added :-
def main():
app.run()
if __name__ == '__main__':
main()
in /var/www/cgi-bin/hello_world.py
================================================================================
Now my Configuration of /etc/apache2/sites-available/default in under
<VirtualHost *:80>
ServerAdmin webmaster at localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
AddHandler mod_python .py
PythonHandler mod_python.publisher | .py
AddHandler mod_python .psp .psp_
PythonHandler mod_python.psp | .psp .psp
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin/">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride None
Order allow,deny
allow from all
AddHandler cgi-script cgi pl
</Directory>
#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script cgi pl
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
===============================================================================
my code is under /var/www/cgi-bin/hello_world.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')
app = webapp2.WSGIApplication([('/', MainPage)],
debug=True)
def main():
app.run()
if __name__ == '__main__':
main()
=============================================================================
extra thing i did
in /etc/apache2/mods-available/mod_python.conf
where i created the file "mod_python.conf"
<IfModule mod_python.c>
AddHandler mod_python .py .psp
PythonHandler mod_python.publisher | .py
PythonHandler mod_python.psp | .psp
</IfModule>
################################################################################
when i run localhost/cgi-bin/hello_world.py
error i get
Not Found
The requested URL /cgi-bin/hello_world.py was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
#############################################################################
More information about the Python-list
mailing list