From f982ad8ee835191bdfc92d4b7c0c603411f429c4 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 6 Apr 2014 21:20:57 -0700 Subject: [PATCH] More docs on Apache --- Apache.md | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Apache.md b/Apache.md index fda1b62..765fb04 100644 --- a/Apache.md +++ b/Apache.md @@ -8,7 +8,7 @@ For kirsle.net I needed to set it up using `mod_fcgid` because my site has a lot of legacy URLs to old static files, so Rophako needs to serve the main website pages and Apache needs to serve everything else. -* Apache configuration: +## Apache configuration: ```apache # Rophako www.kirsle.net @@ -36,7 +36,9 @@ pages and Apache needs to serve everything else. ``` -* `~/www/.htaccess` configuration: +## .htaccess configuration: + +This goes in `~/www/.htaccess` ```apache @@ -48,3 +50,38 @@ pages and Apache needs to serve everything else. RewriteRule ^$ /fcgi/index.fcgi/ [QSA,L] ``` + +## FastCGI script + +This is my FastCGI script I wrote to launch Rophako. Important things to note: + +* The shebang line points to the Python binary in my virtualenv. +* I modify sys.path and chdir to my git checkout folder for Rophako. +* The `ScriptNameStripper` allows `mod_rewrite` to work best. Without it you'll + sometimes get URL paths like `/fcgi/index.fcgi/blog/entry/...` etc. from Flask + because that's what it thinks its path is. + +```python +#!/home/kirsle/.virtualenv/rophako/bin/python + +import os +import sys +sys.path.append("/home/kirsle/git/rophako") +os.chdir("/home/kirsle/git/rophako") + +from flup.server.fcgi import WSGIServer +from rophako import app + +class ScriptNameStripper(object): + 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() +```