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
Provenance
- Commit
06d9a5e- Tree
8074766- Author
defuz <defuz.net@gmail.com>- Committer
defuz <defuz.net@gmail.com>- Parent
ad011bc
7 files changed+19 added−19 removed
modified:docs/deploying/fastcgi.rst+5 added-5 removed
38 unmodified lines39 40 The path has to be the exact same path you define in the server41 config.42 43-Save the `yourapplication.fcgi` file somewhere you will find it again.44-It makes sense to have that in `/var/www/yourapplication` or something43+Save the :file:`yourapplication.fcgi` file somewhere you will find it again.44+It makes sense to have that in :file:`/var/www/yourapplication` or something45 similar.46 47 Make sure to set the executable bit on that file so that the servers48 can execute it:6 unmodified lines55 ------------------56 57 The example above is good enough for a basic Apache deployment but your58 `.fcgi` file will appear in your application URL e.g.59-example.com/yourapplication.fcgi/news/. There are few ways to configure59+``example.com/yourapplication.fcgi/news/``. There are few ways to configure60 your application so that yourapplication.fcgi does not appear in the URL.61 A preferable way is to use the ScriptAlias and SetHandler configuration62 directives to route requests to the FastCGI server. The following example63 uses FastCgiServer to start 5 instances of the application which will88 unmodified lines152 "^(/.*)$" => "/yourapplication.fcgi$1"153 )154 155 Remember to enable the FastCGI, alias and rewrite modules. This configuration156-binds the application to `/yourapplication`. If you want the application to156+binds the application to ``/yourapplication``. If you want the application to157 work in the URL root you have to work around a lighttpd bug with the158 :class:`~werkzeug.contrib.fixers.LighttpdCGIRootFix` middleware.159 160 Make sure to apply it only if you are mounting the application the URL18 unmodified lines179 fastcgi_param SCRIPT_NAME $fastcgi_script_name;180 fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;181 }182 183-This configuration binds the application to `/yourapplication`. If you183+This configuration binds the application to ``/yourapplication``. If you184 want to have it in the URL root it's a bit simpler because you don't185 have to figure out how to calculate ``PATH_INFO`` and ``SCRIPT_NAME``::186 187 location / { try_files $uri @yourapplication; }53 unmodified linesmodified:docs/deploying/mod_wsgi.rst+1 added-1 removed
63 unmodified lines64 If you don't have a factory function for application creation but a singleton65 instance you can directly import that one as `application`.66 67 Store 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 all69 the libraries that are in use are on the python load path. If you don't70 want to install it system wide consider using a `virtual python`_71 instance. Keep in mind that you will have to actually install your72 application into the virtualenv as well. Alternatively there is the125 unmodified linesmodified:docs/deploying/uwsgi.rst+1 added-1 removed
49 unmodified lines50 uwsgi_modifier1 30;51 uwsgi_pass unix:/tmp/uwsgi.sock;52 }53 54-This configuration binds the application to `/yourapplication`. If you want54+This configuration binds the application to ``/yourapplication``. If you want55 to have it in the URL root it's a bit simpler because you don't have to tell56 it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::57 58 location / { try_files $uri @yourapplication; }9 unmodified linesmodified:docs/patterns/appdispatch.rst+2 added-2 removed
57 unmodified lines58 here is that each Flask application is a valid WSGI application and they59 are combined by the dispatcher middleware into a larger one that60 dispatched based on prefix.61 62-For example you could have your main application run on `/` and your63-backend interface on `/backend`::62+For example you could have your main application run on ``/`` and your63+backend interface on ``/backend``::64 65 from werkzeug.wsgi import DispatcherMiddleware66 from frontend_app import application as frontend67 from backend_app import application as backend121 unmodified linesmodified:docs/patterns/fabric.rst+7 added-7 removed
82 unmodified lines83 84 $ fab pack deploy85 86 However 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. Furthermore89 are we not creating the configuration or `.wsgi` file on the server. So90 how do we bootstrap a new server into our infrastructure?91 92 This now depends on the number of servers we want to set up. If we just6 unmodified lines99 $ fab -H newserver.example.com bootstrap100 101 To setup a new server you would roughly do these steps:102 103-1. Create the directory structure in ``/var/www``::103+1. Create the directory structure in :file:`/var/www`::104 105 $ mkdir /var/www/yourapplication106 $ cd /var/www/yourapplication107 $ virtualenv --distribute env108 109-2. Upload a new `application.wsgi` file to the server and the110- configuration file for the application (eg: `application.cfg`)109+2. Upload a new :file:`application.wsgi` file to the server and the110+ configuration file for the application (eg: :file:`application.cfg`)111 112-3. Create a new Apache config for `yourapplication` and activate it.112+3. 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 lines150 151 A popular approach is to store configuration files for different servers152 in a separate version control repository and check them out on all153 servers. Then symlink the file that is active for the server into the154-location where it's expected (eg: ``/var/www/yourapplication``).154+location where it's expected (eg: :file:`/var/www/yourapplication`).155 156 Either way, in our case here we only expect one or two servers and we can157 upload them ahead of time by hand.158 38 unmodified linesmodified:docs/patterns/packages.rst+2 added-2 removed
19 unmodified lines20 Simple Packages21 ---------------22 23 To 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.25 Then rename :file:`yourapplication.py` to :file:`__init__.py`. (Make sure to delete26 all `.pyc` files first, otherwise things would most likely break)27 28 You should then end up with something like that::12 unmodified lines41 But how do you run your application now? The naive ``python42 yourapplication/__init__.py`` will not work. Let's just say that Python43 does not want modules in packages to be the startup file. But that is not44 a 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::46 47 from yourapplication import app48 app.run(debug=True)49 66 unmodified linesmodified:docs/quickstart.rst+1 added-1 removed
369 unmodified lines370 Dynamic web applications also need static files. That's usually where371 the CSS and JavaScript files are coming from. Ideally your web server is372 configured to serve them for you, but during development Flask can do that373 as well. Just create a folder called :file:`static` in your package or next to374-your module and it will be available at `/static` on the application.374+your module and it will be available at ``/static`` on the application.375 376 To generate URLs for static files, use the special ``'static'`` endpoint name::377 378 url_for('static', filename='style.css')515 unmodified lines