Getting ready

Check that your project configuration doesn't raise warnings when you run the following:

(env)$ python manage.py check --deploy --settings=myproject.settings.production

Make sure to have the latest stable version of Ansible.

Choose a server provider and create a dedicated server there with root access via ssh by private and public key authentication. My provider of choice is DigitalOcean (https://www.digitalocean.com/). At DigitalOcean control panel, I created a dedicated server (Droplet) with Ubuntu 18. I can connect to the server by its IP of 46.101.136.102 using a new SSH private and public key pair, ~/.ssh/id_rsa_django_cookbook and ~/.ssh/id_rsa_django_cookbook.pub respectively.

Locally, we need to configure SSH connections by creating or modifying a ~/.ssh/config file with the following content:

# ~/.ssh/config
Host *
ServerAliveInterval 240
AddKeysToAgent yes
UseKeychain yes

Host github
Hostname github.com
IdentityFile ~/.ssh/id_rsa_github

Host myproject-nginx
Hostname 46.101.136.102
User root
IdentityFile ~/.ssh/id_rsa_django_cookbook

Now we should be able to connect to the dedicated server as the root user via ssh using this command:

$ ssh myproject-nginx

In your domain configuration, point the DNS A record of your domain to the IP address of the dedicated server. In our case, we will just be using myproject.46.101.136.102.xip.io to show how to set up the server with an SSL certificate for the Django website.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.181.81