Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (33 sloc) 1.661 kb
layout title
CGI deployment on Apache

CGI deployment on Apache

Here are the simple steps needed to create and run an application.

  • Install and flups

  • Create the application as documented

    if __name__ == "__main__":, globals())

For our example, let it be named, located in /www/app and we need it accessible as http://server/app/

  • Configure Apache (version 2.2 in this example)

    ScriptAlias /app "/www/app/"
    <Directory "/www/app/">
            Options +ExecCGI +FollowSymLinks
            Order allow,deny
            Allow from all

That's it. Your application is accessible via http://server/app/ Additional URLs handled by the application are added to the end of the URL, for examples http://server/app/

  • .htaccess configuration

          Options +ExecCGI
          AddHandler cgi-script .py
          <IfModule mod_rewrite.c>
              RewriteEngine on
              RewriteBase /
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_URI} !^/favicon.ico$
              RewriteCond %{REQUEST_URI} !^(/.*)
              RewriteRule ^(.*)$$1 [PT]

Here it is assumed that your application is called The above htaccess checks if some static file/directory exists failing which it routes the data to your Change the Rewrite Base to a sub-directory if needed.

Jump to Line
Something went wrong with that request. Please try again.