MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

  • Python
  • modwsgi

Contents

  1. modwsgi
    1. Ubuntu installation 12.04
    2. Slackware 14 installation

modwsgi

Python WSGI adapter module for Apache.

  • http://code.google.com/p/modwsgi/

  • https://github.com/GrahamDumpleton/mod_wsgi

Ubuntu installation 12.04

Toggle line numbers
   1 apt-get install libapache2-mod-wsgi
   2 service apache2 restart

Create file /var/www/test.wsgi

Toggle line numbers
   1 def application(environ, start_response):
   2     status = '200 OK'
   3     output = 'Hello World! Mod WSGI running'
   4 
   5     response_headers = [('Content-type', 'text/plain'),
   6                         ('Content-Length', str(len(output)))]
   7     start_response(status, response_headers)
   8 
   9     return [output]

Add to file /etc/apache2/sites-available/default inside the Virtual host the following

Toggle line numbers
   1 WSGIScriptAlias /test /var/www/test.wsgi

Slackware 14 installation

Toggle line numbers
   1 wget http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-3.4.tar.gz&can=1&q=
   2 cp mod_wsgi-3.4.tar.gz /tmp
   3 cd /tmp
   4 tar xvzf mod_wsgi-3.4.tar.gz
   5 cd mod_wsgi-3.4
   6 ./configure
   7 make clean
   8 make 
   9 make install
  10 ldconfig
  11 ls /usr/lib/httpd/modules #should appear file mod_wsgi.so
  12 touch /etc/httpd/mod_wsgi.conf

Edit file /etc/httpd/httpd.conf and add

Toggle line numbers
   1 Include /etc/httpd/mod_wsgi.conf
   2 Include /etc/httpd/vhosts.conf

Edit file /etc/httpd/mod_wsgi.conf and add

Toggle line numbers
   1 LoadModule wsgi_module /usr/lib/httpd/modules/mod_wsgi.so

Restart apache with

Toggle line numbers
   1 /etc/rc.d/rc.httpd restart

Check if mod_wsgi module is loaded with

  • tail /var/log/httpd/error_log | grep wsgi
  • Should appear mod_wsgi/3.4

Create test wsgi app

Create file /var/www/htdocs/test/test.wsgi

Toggle line numbers
   1 def application(environ, start_response):
   2     start_response('200 OK', [('Content-Type', 'text/html')])
   3     yield '<html><body><h1>Test WSGI</h1></body></html>'

Create virtual host in /etc/httpd/vhosts.conf

Toggle line numbers
   1 <VirtualHost *:80>
   2     ServerName localhosttestwsgi
   3     DocumentRoot "/var/www/htdocs/test"
   4     WSGIScriptAlias / /var/www/htdocs/test/test.wsgi
   5     ErrorLog /var/log/localhosttestwsgi-error_log
   6     CustomLog /var/log/localhosttestwsgi-access_log common
   7     <Directory "/var/www/htdocs/test">
   8       Require local
   9     </Directory>
  10 </VirtualHost>

Add host to /etc/hosts

Toggle line numbers
   1 127.0.0.1 localhosttestwsgi

Restart apache

Toggle line numbers
   1 /etc/rc.d/rc.httpd restart

Open url http://localhosttestwsgi/ and see if the string Test WSGI appears.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01