forked from orbit-oss/flask
Add detailed Apache httpd fastcgi configuration.
This commit is contained in:
parent
a3cb2a3382
commit
34380b9c1d
1 changed files with 57 additions and 3 deletions
|
|
@ -51,6 +51,61 @@ can execute it:
|
||||||
|
|
||||||
# chmod +x /var/www/yourapplication/yourapplication.fcgi
|
# chmod +x /var/www/yourapplication/yourapplication.fcgi
|
||||||
|
|
||||||
|
Configuring Apache
|
||||||
|
------------------
|
||||||
|
|
||||||
|
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::
|
||||||
|
|
||||||
|
<VirtualHost *>
|
||||||
|
ServerName example.com
|
||||||
|
ScriptAlias / /path/to/yourapplication.fcgi/
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
Another way is to use a custom WSGI middleware. For example on a shared web hosting::
|
||||||
|
|
||||||
|
.htaccess
|
||||||
|
|
||||||
|
<IfModule mod_fcgid.c>
|
||||||
|
AddHandler fcgid-script .fcgi
|
||||||
|
<Files ~ (\.fcgi)>
|
||||||
|
SetHandler fcgid-script
|
||||||
|
Options +FollowSymLinks +ExecCGI
|
||||||
|
</Files>
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
Options +FollowSymlinks
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^(.*)$ yourapplication.fcgi/$1 [QSA,L]
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
yourapplication.fcgi
|
||||||
|
|
||||||
|
#!/usr/bin/python
|
||||||
|
#: optional path to your local python site-packages folder
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, '<your_local_path>/lib/python2.6/site-packages')
|
||||||
|
|
||||||
|
from flup.server.fcgi import WSGIServer
|
||||||
|
from yourapplication import app
|
||||||
|
|
||||||
|
class ScriptNameStripper(object):
|
||||||
|
to_strip = '/yourapplication.fcgi'
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
def __call__(self, environ, start_response):
|
||||||
|
environ['SCRIPT_NAME'] = ''
|
||||||
|
return self.app(environ, start_response)
|
||||||
|
|
||||||
|
app = ScriptNameStripper(app)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
WSGIServer(app).run()
|
||||||
|
|
||||||
Configuring lighttpd
|
Configuring lighttpd
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
@ -84,7 +139,6 @@ root. Also, see the Lighty docs for more information on `FastCGI and
|
||||||
Python <http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI>`_
|
Python <http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI>`_
|
||||||
(note that explicitly passing a socket to run() is no longer necessary).
|
(note that explicitly passing a socket to run() is no longer necessary).
|
||||||
|
|
||||||
|
|
||||||
Configuring nginx
|
Configuring nginx
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
@ -97,7 +151,7 @@ A basic flask FastCGI configuration for nginx looks like this::
|
||||||
location /yourapplication { try_files $uri @yourapplication; }
|
location /yourapplication { try_files $uri @yourapplication; }
|
||||||
location @yourapplication {
|
location @yourapplication {
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_split_path_info ^(/yourapplication)(.*)$;
|
fastcgi_split_path_info ^(/yourapplication)(.*)$;
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;
|
fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue