Docker – uwsgi – nginx – Django

 1. Assume
– Docker is already installed [Link]
– Django & it’s project is ready [Link]
– Postgres or MySQL is ready [Link]
– Python3
– CentOS 7

  2. Install Packages

yum install uwsgi
yum install nginx

 3. Create Uwsgi conf file
– Location : doesn’t matter , where you want..
– Name : whatever you want (*.ini)

[uwsgi]
project = firstsite
base = /home/user

chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application

master = true
processes = 5

socket = %(base)/%(project)/%(project).sock
chmod-socket = 664
vacuum = true

 4. Run Uwsgi

uwsgi ./<*.ini file> --emperor <Django Project Home> &

 5. Edit Nginx conf file
– Location : /etc/nginx/nginx.conf

server {
    listen <port>;
    server_name <servername>;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/dev/<project>/<project>/static;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/home/dev/<project>/<project>.sock;
    }
}

 6. Run Nginx

/usr/sbin/nginx

 7. Test

http://<ip>:<port>

 

Leave a Reply

Your email address will not be published. Required fields are marked *