Version 15 (modified by Fran Boon, 15 years ago) ( diff )


Installation on Apache with WSGI

This is what is used to host the Demo site & Trac (sharing just 128Mb RAM!)

If running on a UNIX variant (as would be recommended) then suggest using the Native Cron

vim /etc/crontab
0-59/1 * * * * www-data cd /var/www/web2py/ && python -C -D 1 >> /tmp/cron.output 2>&1

cp /var/www/web2py/ /var/www/web2py/
vim /var/www/web2py/
extcron = True


apt-get install libapache2-mod-wsgi
a2enmod rewrite
a2enmod deflate
a2enmod headers
a2enmod expires
vim /etc/apache2/sites-available/web2py
<VirtualHost ip.ip.ip.ip:80>
  DocumentRoot /var/www/web2py/applications 

  WSGIScriptAlias / /var/www/web2py/
  WSGIDaemonProcess web2py user=www-data group=www-data home=/var/www/web2py processes=10 maximum-requests=500

  RewriteEngine On
  RewriteRule ^/$ /sahana/ [R]

  ### admin only accessible via SSH Tunnel
  <Location "/admin">
  ### appadmin requires SSL
  <LocationMatch "^(/[\w_]*/appadmin/.*)">
  ### static files do not need WSGI
  <LocationMatch "^(/[\w_]*/static/.*)">
    Order Allow,Deny
    Allow from all
  ### everything else goes over WSGI
  <Location "/">
    Order deny,allow
    Allow from all
    WSGIProcessGroup web2py

  ErrorLog /var/log/apache2/demo_error.log
  LogLevel warn
  CustomLog /var/log/apache2/demo_access.log combined

Optimise by using GZip & Expires:

  ### static files do not need WSGI
  <LocationMatch "^(/[\w_]*/static/.*)">
    Order Allow,Deny
    Allow from all

    SetOutputFilter DEFLATE
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    Header append Vary User-Agent env=!dont-vary

    ExpiresActive On
    ExpiresByType text/html "access plus 1 day"
    ExpiresByType text/javascript "access plus 1 week"
    ExpiresByType text/css "access plus 2 weeks"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
ln -s /etc/apache2/sites-available/web2py /etc/apache2/sites-enabled/web2py
/etc/init.d/apache2 force-reload

WSGI Installation comments:


Note: See TracWiki for help on using the wiki.