Figure 8-5. Broken CSS
Getting Nginx to Serve Static Files
First we run
collectstatic
to copy all the static files to a folder where Nginx can find
them:
elspeth@server:$
../virtualenv/bin/python3 manage.py collectstatic --noinput
elspeth@server:$
ls ../static/
base.css bootstrap
Note that, again, instead of using the virtualenv
activate
command, we can use the
direct path to the virtualenv’s copy of Python instead.
Now we tell Nginx to start serving those static files for us:
server: /etc/nginx/sites-available/superlists-staging.ottg.eu.
server
{
listen
80
;
server_name
superlists-staging.ottg.eu
;
location
/static
{
alias
/home/elspeth/sites/superlists-staging.ottg.eu/static
;
}
location
/
{
proxy_pass
http://localhost:8000
;
Getting to a Production-Ready Deployment
|
149