Skip to content
Myr

docs: :file:`/var/www/foo`, ``/static``

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by defuz · committed by defuz · parent ad011bc · Browse files · 7 files+19 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+19 added−19 removed

  • other:+19 added−19 removed

7 files+19 added−19 removed

modified:docs/deploying/fastcgi.rst+5 added-5 removed
38 unmodified lines
3940The path has to be the exact same path you define in the server41config.4243Save the `yourapplication.fcgi` file somewhere you will find it again.44It makes sense to have that in `/var/www/yourapplication` or something43Save the :file:`yourapplication.fcgi` file somewhere you will find it again.44It makes sense to have that in :file:`/var/www/yourapplication` or something45similar.4647Make sure to set the executable bit on that file so that the servers48can execute it:
6 unmodified lines
55------------------5657The example above is good enough for a basic Apache deployment but your58`.fcgi` file will appear in your application URL e.g.59example.com/yourapplication.fcgi/news/. There are few ways to configure59``example.com/yourapplication.fcgi/news/``. There are few ways to configure60your application so that yourapplication.fcgi does not appear in the URL.61A preferable way is to use the ScriptAlias and SetHandler configuration62directives to route requests to the FastCGI server. The following example63uses FastCgiServer to start 5 instances of the application which will
88 unmodified lines
152 "^(/.*)$" => "/yourapplication.fcgi$1"153 )154155Remember to enable the FastCGI, alias and rewrite modules. This configuration156binds the application to `/yourapplication`. If you want the application to156binds the application to ``/yourapplication``. If you want the application to157work in the URL root you have to work around a lighttpd bug with the158:class:`~werkzeug.contrib.fixers.LighttpdCGIRootFix` middleware.159160Make sure to apply it only if you are mounting the application the URL
18 unmodified lines
179 fastcgi_param SCRIPT_NAME $fastcgi_script_name;180 fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;181 }182183This configuration binds the application to `/yourapplication`. If you183This configuration binds the application to ``/yourapplication``. If you184want to have it in the URL root it's a bit simpler because you don't185have to figure out how to calculate ``PATH_INFO`` and ``SCRIPT_NAME``::186187 location / { try_files $uri @yourapplication; }
53 unmodified lines
modified:docs/deploying/mod_wsgi.rst+1 added-1 removed
63 unmodified lines
64If you don't have a factory function for application creation but a singleton65instance you can directly import that one as `application`.6667Store that file somewhere that you will find it again (e.g.:68`/var/www/yourapplication`) and make sure that `yourapplication` and all68:file:`/var/www/yourapplication`) and make sure that `yourapplication` and all69the libraries that are in use are on the python load path. If you don't70want to install it system wide consider using a `virtual python`_71instance. Keep in mind that you will have to actually install your72application into the virtualenv as well. Alternatively there is the
125 unmodified lines
modified:docs/deploying/uwsgi.rst+1 added-1 removed
49 unmodified lines
50 uwsgi_modifier1 30;51 uwsgi_pass unix:/tmp/uwsgi.sock;52 }5354This configuration binds the application to `/yourapplication`. If you want54This configuration binds the application to ``/yourapplication``. If you want55to have it in the URL root it's a bit simpler because you don't have to tell56it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::5758 location / { try_files $uri @yourapplication; }
9 unmodified lines
modified:docs/patterns/appdispatch.rst+2 added-2 removed
57 unmodified lines
58here is that each Flask application is a valid WSGI application and they59are combined by the dispatcher middleware into a larger one that60dispatched based on prefix.6162For example you could have your main application run on `/` and your63backend interface on `/backend`::62For example you could have your main application run on ``/`` and your63backend interface on ``/backend``::6465 from werkzeug.wsgi import DispatcherMiddleware66 from frontend_app import application as frontend67 from backend_app import application as backend
121 unmodified lines
modified:docs/patterns/fabric.rst+7 added-7 removed
82 unmodified lines
8384 $ fab pack deploy8586However this requires that our server already has the87``/var/www/yourapplication`` folder created and88``/var/www/yourapplication/env`` to be a virtual environment. Furthermore87:file:`/var/www/yourapplication` folder created and88:file:`/var/www/yourapplication/env` to be a virtual environment. Furthermore89are we not creating the configuration or `.wsgi` file on the server. So90how do we bootstrap a new server into our infrastructure?9192This now depends on the number of servers we want to set up. If we just
6 unmodified lines
99 $ fab -H newserver.example.com bootstrap100101To setup a new server you would roughly do these steps:1021031. Create the directory structure in ``/var/www``::1031. Create the directory structure in :file:`/var/www`::104105 $ mkdir /var/www/yourapplication106 $ cd /var/www/yourapplication107 $ virtualenv --distribute env1081092. Upload a new `application.wsgi` file to the server and the110 configuration file for the application (eg: `application.cfg`)1092. Upload a new :file:`application.wsgi` file to the server and the110 configuration file for the application (eg: :file:`application.cfg`)1111123. Create a new Apache config for `yourapplication` and activate it.1123. Create a new Apache config for ``yourapplication`` and activate it.113 Make sure to activate watching for changes of the `.wsgi` file so114 that we can automatically reload the application by touching it.115 (See :ref:`mod_wsgi-deployment` for more information)116
33 unmodified lines
150151A popular approach is to store configuration files for different servers152in a separate version control repository and check them out on all153servers. Then symlink the file that is active for the server into the154location where it's expected (eg: ``/var/www/yourapplication``).154location where it's expected (eg: :file:`/var/www/yourapplication`).155156Either way, in our case here we only expect one or two servers and we can157upload them ahead of time by hand.158
38 unmodified lines
modified:docs/patterns/packages.rst+2 added-2 removed
19 unmodified lines
20Simple Packages21---------------2223To convert that into a larger one, just create a new folder24`yourapplication` inside the existing one and move everything below it.24:file:`yourapplication` inside the existing one and move everything below it.25Then rename :file:`yourapplication.py` to :file:`__init__.py`. (Make sure to delete26all `.pyc` files first, otherwise things would most likely break)2728You should then end up with something like that::
12 unmodified lines
41But how do you run your application now? The naive ``python42yourapplication/__init__.py`` will not work. Let's just say that Python43does not want modules in packages to be the startup file. But that is not44a big problem, just add a new file called :file:`runserver.py` next to the inner45`yourapplication` folder with the following contents::45:file:`yourapplication` folder with the following contents::4647 from yourapplication import app48 app.run(debug=True)49
66 unmodified lines
modified:docs/quickstart.rst+1 added-1 removed
369 unmodified lines
370Dynamic web applications also need static files. That's usually where371the CSS and JavaScript files are coming from. Ideally your web server is372configured to serve them for you, but during development Flask can do that373as well. Just create a folder called :file:`static` in your package or next to374your module and it will be available at `/static` on the application.374your module and it will be available at ``/static`` on the application.375376To generate URLs for static files, use the special ``'static'`` endpoint name::377378 url_for('static', filename='style.css')
515 unmodified lines