![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0173.png)
2. Not sure how to edit a file on the server? There’s always vi, which I’ll keep encouraging you to learn a bit of.
Alternatively, try the relatively beginner-friendly
nano
. Note you’ll also need to use
sudo
because the file is
in a system folder.
server: /etc/nginx/sites-available/superlists-staging.ottg.eu.
server
{
listen
80
;
server_name
superlists-staging.ottg.eu
;
location
/
{
proxy_pass
http://localhost:8000
;
}
}
This config says it will only work for our staging domain, and will “proxy” all requests
to the local port 8000 where it expects to find Django waiting to respond to requests.
I saved
2
this to a file called
superlists-staging.ottg.eu
inside
/etc/nginx/sites-available
folder, and then added it to the enabled sites for the server by creating a symlink to it:
elspeth@server:$
echo $SITENAME
# check this still has our site in
superlists-staging.ottg.eu
elspeth@server:$
sudo ln -s ../sites-available/$SITENAME \
/etc/nginx/sites-enabled/$SITENAME
elspeth@server:$
ls -l /etc/nginx/sites-enabled
# check our symlink is there
That’s the Debian/Ubuntu preferred way of saving Nginx configurations—the real con‐
fig file in
sites-available
, and a symlink in
sites-enabled
; the idea is that it makes it easier
to switch sites on or off.
We also may as well remove the default “Welcome to nginx” config, to avoid any
confusion:
elspeth@server:$
sudo rm /etc/nginx/sites-enabled/default
And now to test it:
elspeth@server:$
sudo service nginx reload
elspeth@server:$
../virtualenv/bin/python3 manage.py runserver
I also had to edit
/etc/nginx/nginx.conf
and uncomment a line
saying
server_names_hash_bucket_size 64;
to get my long do‐
main name to work. You may not have this problem; Nginx will
warn you when you do a
reload
if it has any trouble with its config
files.
A quick visual inspection confirms—the site is up
( Figure 8-3 )!
Deploying Our Code Manually
|
145