Reordered deployment docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent 5310fc3 · Browse files · 1 file·+127 added−126 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+127 added−126 removed
- other:+127 added−126 removed
Provenance
- Commit
b9cae35- Tree
2434ead- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
5310fc3
1 file changed+127 added−126 removed
modified:docs/deploying.rst+127 added-126 removed
9 unmodified lines10 how to use a WSGI app with it. Just remember that your application object11 is the actual WSGI application.12 13 14+mod_wsgi (Apache)15+-----------------16+17+If you are using the `Apache`_ webserver you should consider using `mod_wsgi`_.18+19+.. _Apache: http://httpd.apache.org/20+21+Installing `mod_wsgi`22+`````````````````````23+24+If you don't have `mod_wsgi` installed yet you have to either install it using25+a package manager or compile it yourself.26+27+The mod_wsgi `installation instructions`_ cover installation instructions for28+source installations on UNIX systems.29+30+If you are using ubuntu / debian you can apt-get it and activate it as follows::31+32+ # apt-get install libapache2-mod-wsgi33+34+On FreeBSD install `mod_wsgi` by compiling the `www/mod_wsgi` port or by using35+pkg_add::36+37+ # pkg_add -r mod_wsgi38+39+If you are using pkgsrc you can install `mod_wsgi` by compiling the40+`www/ap2-wsgi` package.41+42+If you encounter segfaulting child processes after the first apache reload you43+can safely ignore them. Just restart the server.44+45+Creating a `.wsgi` file46+```````````````````````47+48+To run your application you need a `yourapplication.wsgi` file. This file49+contains the code `mod_wsgi` is executing on startup to get the application50+object. The object called `application` in that file is then used as51+application.52+53+For most applications the following file should be sufficient::54+55+ from yourapplication import app as application56+57+If you don't have a factory function for application creation but a singleton58+instance you can directly import that one as `application`.59+60+Store that file somewhere where you will find it again (eg:61+`/var/www/yourapplication`) and make sure that `yourapplication` and all62+the libraries that are in use are on the python load path. If you don't63+want to install it system wide consider using a `virtual python`_ instance.64+65+Configuring Apache66+``````````````````67+68+The last thing you have to do is to create an Apache configuration file for69+your application. In this example we are telling `mod_wsgi` to execute the70+application under a different user for security reasons:71+72+.. sourcecode:: apache73+74+ <VirtualHost *>75+ ServerName example.com76+77+ WSGIDaemonProcess yourapplication user=user1 group=group1 threads=578+ WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi79+80+ <Directory /var/www/yourapplication>81+ WSGIProcessGroup yourapplication82+ WSGIApplicationGroup %{GLOBAL}83+ Order deny,allow84+ Allow from all85+ </Directory>86+ </VirtualHost>87+88+For more information consult the `mod_wsgi wiki`_.89+90+.. _mod_wsgi: http://code.google.com/p/modwsgi/91+.. _installation instructions: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide92+.. _virtual python: http://pypi.python.org/pypi/virtualenv93+.. _mod_wsgi wiki: http://code.google.com/p/modwsgi/wiki/94+95+96+CGI97+---98+99+If all other deployment methods do not work, CGI will work for sure. CGI100+is supported by all major servers but usually has a less-than-optimal101+performance.102+103+This is also the way you can use a Flask application on Google's104+`AppEngine`_, there however the execution does happen in a CGI-like105+environment. The application's performance is unaffected because of that.106+107+.. _AppEngine: http://code.google.com/appengine/108+109+Creating a `.cgi` file110+``````````````````````111+112+First you need to create the CGI application file. Let's call it113+`yourapplication.cgi`::114+115+ #!/usr/bin/python116+ from wsgiref.handlers import CGIHandler117+ from yourapplication import app118+119+ CGIHandler().run(app)120+121+If you're running Python 2.4 you will need the :mod:`wsgiref` package. Python122+2.5 and higher ship this as part of the standard library.123+124+Server Setup125+````````````126+127+Usually there are two ways to configure the server. Either just copy the128+`.cgi` into a `cgi-bin` (and use `mod_rerwite` or something similar to129+rewrite the URL) or let the server point to the file directly.130+131+In Apache for example you can put a like like this into the config:132+133+.. sourcecode:: apache134+135+ ScriptName /app /path/to/the/application.cgi136+137+For more information consult the documentation of your webserver.138+139+140+141 FastCGI142 -------143 144 A very popular deployment setup on servers like `lighttpd`_ and `nginx`_122 unmodified lines267 .. _nginx: http://nginx.net/268 .. _flup: http://trac.saddi.com/flup269 270 144-mod_wsgi (Apache)145------------------271 147-If you are using the `Apache`_ webserver you should consider using `mod_wsgi`_.148-149-.. _Apache: http://httpd.apache.org/150-151-Installing `mod_wsgi`152-`````````````````````153-154-If you don't have `mod_wsgi` installed yet you have to either install it using155-a package manager or compile it yourself.156-157-The mod_wsgi `installation instructions`_ cover installation instructions for158-source installations on UNIX systems.159-160-If you are using ubuntu / debian you can apt-get it and activate it as follows::161-162- # apt-get install libapache2-mod-wsgi163-164-On FreeBSD install `mod_wsgi` by compiling the `www/mod_wsgi` port or by using165-pkg_add::166-167- # pkg_add -r mod_wsgi168-169-If you are using pkgsrc you can install `mod_wsgi` by compiling the170-`www/ap2-wsgi` package.171-172-If you encounter segfaulting child processes after the first apache reload you173-can safely ignore them. Just restart the server.174-175-Creating a `.wsgi` file176-```````````````````````177-178-To run your application you need a `yourapplication.wsgi` file. This file179-contains the code `mod_wsgi` is executing on startup to get the application180-object. The object called `application` in that file is then used as181-application.182-183-For most applications the following file should be sufficient::184-185- from yourapplication import app as application186-187-If you don't have a factory function for application creation but a singleton188-instance you can directly import that one as `application`.189-190-Store that file somewhere where you will find it again (eg:191-`/var/www/yourapplication`) and make sure that `yourapplication` and all192-the libraries that are in use are on the python load path. If you don't193-want to install it system wide consider using a `virtual python`_ instance.194-195-Configuring Apache196-``````````````````197-198-The last thing you have to do is to create an Apache configuration file for199-your application. In this example we are telling `mod_wsgi` to execute the200-application under a different user for security reasons:201-202-.. sourcecode:: apache203-204- <VirtualHost *>205- ServerName example.com206-207- WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5208- WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi209-210- <Directory /var/www/yourapplication>211- WSGIProcessGroup yourapplication212- WSGIApplicationGroup %{GLOBAL}213- Order deny,allow214- Allow from all215- </Directory>216- </VirtualHost>217-218-For more information consult the `mod_wsgi wiki`_.219-220-.. _mod_wsgi: http://code.google.com/p/modwsgi/221-.. _installation instructions: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide222-.. _virtual python: http://pypi.python.org/pypi/virtualenv223-.. _mod_wsgi wiki: http://code.google.com/p/modwsgi/wiki/224-225-226-272 Tornado273 --------274 275 `Tornado`_ is an open source version of the scalable, non-blocking web server and tools that power `FriendFeed`_.28 unmodified lines304 305 .. _Gevent: http://www.gevent.org/306 .. _greenlet: http://codespeak.net/py/0.9.2/greenlet.html307 .. _libevent: http://monkey.org/~provos/libevent/263-264-CGI265----266-267-If all other deployment methods do not work, CGI will work for sure. CGI268-is supported by all major browsers but usually has a less-than-optimal269-performance.270-271-This is also the way you can use a Flask application on Google's272-`AppEngine`_, there however the execution does happen in a CGI-like273-environment. The application's performance is unaffected because of that.274-275-.. _AppEngine: http://code.google.com/appengine/276-277-Creating a `.cgi` file278-``````````````````````279-280-First you need to create the CGI application file. Let's call it281-`yourapplication.cgi`::282-283- #!/usr/bin/python284- from wsgiref.handlers import CGIHandler285- from yourapplication import app286-287- CGIHandler().run(app)288-289-If you're running Python 2.4 you will need the :mod:`wsgiref` package. Python290-2.5 and higher ship this as part of the standard library.291-292-Server Setup293-````````````294-295-Usually there are two ways to configure the server. Either just copy the296-`.cgi` into a `cgi-bin` (and use `mod_rerwite` or something similar to297-rewrite the URL) or let the server point to the file directly.298-299-In Apache for example you can put a like like this into the config:300-301-.. sourcecode:: apache302-303- ScriptName /app /path/to/the/application.cgi304-305-For more information consult the documentation of your webserver.306-