Add detailed Apache httpd fastcgi configuration.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Vadim Pestovnikov · committed by Ron DuPlain · parent a3cb2a3 · Browse files · 1 file·+57 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+57 added−3 removed
- other:+57 added−3 removed
Provenance
- Commit
34380b9- Tree
f11f246- Author
Vadim Pestovnikov <vadim.pestovnikov@gmail.com>- Committer
Ron DuPlain <ron.duplain@gmail.com>- Parent
a3cb2a3
1 file changed+57 added−3 removed
modified:docs/deploying/fastcgi.rst+57 added-3 removed
49 unmodified lines50 .. sourcecode:: text51 52 # chmod +x /var/www/yourapplication/yourapplication.fcgi53 54+Configuring Apache55+------------------56+57+The example above is good enough for a basic Apache deployment but your `.fcgi` file will appear in your application URL e.g. www.example.com/yourapplication.fcgi/news/. There are few ways to resolve it. A preferable way is to use Apache ScriptAlias configuration directive::58+59+ <VirtualHost *>60+ ServerName example.com61+ ScriptAlias / /path/to/yourapplication.fcgi/62+ </VirtualHost>63+64+Another way is to use a custom WSGI middleware. For example on a shared web hosting::65+66+ .htaccess67+68+ <IfModule mod_fcgid.c>69+ AddHandler fcgid-script .fcgi70+ <Files ~ (\.fcgi)>71+ SetHandler fcgid-script72+ Options +FollowSymLinks +ExecCGI73+ </Files>74+ </IfModule>75+76+ <IfModule mod_rewrite.c>77+ Options +FollowSymlinks78+ RewriteEngine On79+ RewriteBase /80+ RewriteCond %{REQUEST_FILENAME} !-f81+ RewriteRule ^(.*)$ yourapplication.fcgi/$1 [QSA,L]82+ </IfModule>83+84+ yourapplication.fcgi85+86+ #!/usr/bin/python87+ #: optional path to your local python site-packages folder88+ import sys89+ sys.path.insert(0, '<your_local_path>/lib/python2.6/site-packages')90+91+ from flup.server.fcgi import WSGIServer92+ from yourapplication import app93+94+ class ScriptNameStripper(object):95+ to_strip = '/yourapplication.fcgi'96+97+ def __init__(self, app):98+ self.app = app99+100+ def __call__(self, environ, start_response):101+ environ['SCRIPT_NAME'] = ''102+ return self.app(environ, start_response)103+104+ app = ScriptNameStripper(app)105+106+ if __name__ == '__main__':107+ WSGIServer(app).run()108+109 Configuring lighttpd110 --------------------111 112 A basic FastCGI configuration for lighttpd looks like that::25 unmodified lines138 root. Also, see the Lighty docs for more information on `FastCGI and139 Python <http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI>`_140 (note that explicitly passing a socket to run() is no longer necessary).141 87-142 Configuring nginx143 -----------------144 145 Installing FastCGI applications on nginx is a bit different because by4 unmodified lines150 location = /yourapplication { rewrite ^ /yourapplication/ last; }151 location /yourapplication { try_files $uri @yourapplication; }152 location @yourapplication {153 include fastcgi_params;100- fastcgi_split_path_info ^(/yourapplication)(.*)$;154+ fastcgi_split_path_info ^(/yourapplication)(.*)$;155 fastcgi_param PATH_INFO $fastcgi_path_info;156 fastcgi_param SCRIPT_NAME $fastcgi_script_name;157 fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;158 }54 unmodified lines213 214 .. _nginx: http://nginx.org/215 .. _lighttpd: http://www.lighttpd.net/216 .. _cherokee: http://www.cherokee-project.com/163-.. _flup: http://trac.saddi.com/flup217+.. _flup: http://trac.saddi.com/flup