Raportti 4

I decided to create a vps in amsterdam and use cloudflare’s dns service

first i created the droplet in digital ocean

Screenshot from 2018-09-13 16-03-40Screenshot from 2018-09-13 16-04-23Screenshot from 2018-09-13 16-05-43

next step i did was to configure the server for installing nginx

so first

Screenshot from 2018-09-13 16-14-12

first i sshed to the server

then i added my self to sudo and disabled login to ssh by root

and allowed ports 22,80 and 443 in firewall

next i installed nginx

Screenshot from 2018-09-13 16-27-25

then i changed dns settings in cloudflare to match the serverScreenshot from 2018-09-13 16-07-58

next step is to install ssl to the webserver using letsencrypt

after installing ssl with cloudflare you might have this problemScreenshot from 2018-09-13 16-44-06

to solve it go to cloudflare.com and login to your account and click crypto

Screenshot from 2018-09-13 16-45-54

change where it says flexible to full

now your site works

Screenshot from 2018-09-13 16-46-55

now to install django with nginx

Screenshot from 2018-09-13 16-48-54Screenshot from 2018-09-13 16-49-07Screenshot from 2018-09-13 16-50-13

now i switched to the postgres user

next i open the postresql shell

Screenshot from 2018-09-13 16-52-01

CREATE USER myprojectuser WITH PASSWORD ’password’;

creates a user called myprojectuser with the password of ’password’

GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;

grants permission to database ’myproject’ to ’myprojectuser’



to return to your user shell


next step is to install gunicorn service

sudo nano /etc/systemd/system/gunicorn.service

Description=gunicorn daemon



start server contents


PYTHONPATH=`pwd`/ /home/omar/myproject/myprojectenv/bin/gunicorn –workers 3 –bind unix:/home/omar/myproject/myproject.sock myproject.wsgi:application

this is the gunicorn socket required for nginx

location / {
include proxy_params;
proxy_pass http://unix:/home/omar/myproject/myproject.sock;

is the only change to nginx configuration

and django settings

Screenshot from 2018-09-13 17-46-55Screenshot from 2018-09-13 17-43-22

default site of django

https://omarbenchbana.com/hello/Screenshot from 2018-09-13 18-24-50.png



Täytä tietosi alle tai klikkaa kuvaketta kirjautuaksesi sisään:


Olet kommentoimassa WordPress.com -tilin nimissä. Log Out /  Muuta )

Google photo

Olet kommentoimassa Google -tilin nimissä. Log Out /  Muuta )


Olet kommentoimassa Twitter -tilin nimissä. Log Out /  Muuta )


Olet kommentoimassa Facebook -tilin nimissä. Log Out /  Muuta )

Muodostetaan yhteyttä palveluun %s