From d09d38323e3caea2b273c875e8e6e04b85be845d Mon Sep 17 00:00:00 2001 From: ohsc Date: Wed, 20 Jan 2010 08:34:27 +0000 Subject: [PATCH] edit --- cookbook/cgi-apache.zh-cn.md | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 cookbook/cgi-apache.zh-cn.md diff --git a/cookbook/cgi-apache.zh-cn.md b/cookbook/cgi-apache.zh-cn.md new file mode 100644 index 00000000..a44be178 --- /dev/null +++ b/cookbook/cgi-apache.zh-cn.md @@ -0,0 +1,45 @@ +--- +layout: default +title: CGI deployment on Apache +--- + +# CGI deployment on Apache + +Here are the simple steps needed to create and run an web.py application. + +* Install web.py and flups + +* Create the application as documented + + if __name__ == "__main__": + web.run(urls, globals()) + +For our example, let it be named `app.py`, located in `/www/app` and we need it accessible as `http://server/app/app.py`. + +* Configure Apache (version 2.2 in this example) + + ScriptAlias /app "/www/app/" + + Options +ExecCGI +FollowSymLinks + Order allow,deny + Allow from all + + +That's it. Your application is accessible via `http://server/app/app.py/`. Additional URLs handled by the application are added to the end of the URL, for examples `http://server/app/app.py/myurl`. + +* .htaccess configuration + + Options +ExecCGI + AddHandler cgi-script .py + DirectoryIndex index.py + + RewriteEngine on + RewriteBase / + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} !^/favicon.ico$ + RewriteCond %{REQUEST_URI} !^(/.*)+index.py/ + RewriteRule ^(.*)$ index.py/$1 [PT] + + +Here it is assumed that your application is called index.py. The above htaccess checks if some static file/directory exists failing which it routes the data to your index.py. Change the Rewrite Base to a sub-directory if needed. \ No newline at end of file