Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
110 lines (82 sloc) 2.92 KB
layout title
default using FastCGI and Apache 2 using FastCGI and Apache 2


Note, on CentOS compiling mod_fcgid requires apache-devel be installed (available via yum).

Apache Configuration

Replace '/var/www/myapp/' with the path to your apps directory

LoadModule rewrite_module modules/
LoadModule fcgid_module modules/

SocketPath /tmp/fcgidsock
SharememPath /tmp/fcgid_shm

Alias /static "/var/www/myapp/static"
Alias / "/var/www/myapp/"
<Directory "/var/www/myapp/">
    allow from all
    SetHandler fcgid-script    
    Options +ExecCGI
    AllowOverride None
    <IfModule mod_rewrite.c>      
       RewriteEngine on
       RewriteBase /
       RewriteCond %{REQUEST_URI} !^/icons
       RewriteCond %{REQUEST_URI} !^/favicon.ico$
       RewriteCond %{REQUEST_URI} !^(/.*)
       RewriteRule ^(.*)$$1 [PT]

<Directory "/var/www/myapp/static">
      allow from all
      AllowOverride None
      Options -ExecCGI
      SetHandler None

Hello World

Note the following line is required: web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)


import web

urls = ("/.*", "hello")
app = web.application(urls, globals())

class hello: 
    def GET(self):
        return 'Hello, world!'

web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
if __name__ == "__main__":


  1. Start your server.
  2. Open your application with your browser
  3. To confirm your application is running try:

ps aux | grep


Check your apache error log for information!

Common problems

File permissions.

You might see error code 255 in your logs. Ensure the directory is readable and that code. py is executable:

chmod +x

404 Not Found.

Is your Alias path correct in your apache configuration?

Other problems spawns, dies unexpectedly, or returns nothing. Did you add this line?

 web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)


  • After updating your application you may need to restart your web server to see the changes.
  • If you do not have root access to your Apache server, you may not have access to all of the above commands in the .htaccess file in your project directory. See this githup repository for a first-draft workaround, using hosted server on (This is a hack written by someone who doesn't understand Apache and thoroughly.)
Something went wrong with that request. Please try again.