C
C
Cyrus2014-11-30 19:31:04
Django
Cyrus, 2014-11-30 19:31:04

Deploy django to freebsd+nginx+uwsgi?

Good afternoon, the question arose of deploying an application to a freebsd 10.0 server with nginx + uwsgi, until it can be launched. I made an ini file

[uwsgi]
    socket = /tmp/intra.sock
    master = true
    chdir = /home/webapps/intranet_project/project/
    pythonpath = /home/webapps/intranet_project/env/lib/python2.7/site-packages
    env = DJANGO_SETTINGS_MODULE=project.settings
    module = django.core.handlers.wsgi:WSGIHandler()
    processes = 4
    threads = 2
    uid = 80
    gid = 1004
    stats = 127.0.0.1:9191
    vacuum = true

wrote in nginx config:
upstream django {
    server unix:///tmp/intra.sock; # for a file socket
    #server 127.0.0.1:8001;
    }

    server {
        listen       8000;
        server_name  intra.lenkuz.ru;

        charset utf-8;

        access_log  /home/webapps/intranet_project/logs/intra.access.log;
        error_log   /home/webapps/intranet_project/logs/intra.error.log;

        location /static {
            alias /home/webapps/intranet_project/project/static; # your Django project's static files - amend as required
        }

        location /media {
            alias /home/webapps/intranet_project/project/static/media;
        }

        location / {
            uwsgi_pass django;
            include /home/webapps/intranet_project/conf/uwsgi_params;
        }

        #location /static/ {
        # а вот здесь указываем абсолютный путь к директории со
        # статическими файлами
        #alias /home/webapps/intranet_project/project/static/;
        #expires 30d;
        #}

    }

But how to make it all work while there is not enough tyam.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2014-12-01
@Novakuz

Home parameter is missing with virtualenv
uwsgi-docs.readthedocs.org/en/latest/Options.html#...
For starters, you can run it from the console - you will immediately understand what is wrong
https://docs.djangoproject.com/en /dev/howto/deploy...

uwsgi --chdir=/path/to/your/project \
    --module=mysite.wsgi:application \
    --env DJANGO_SETTINGS_MODULE=mysite.settings \
    --master --pidfile=/tmp/project-master.pid \
    --socket=127.0.0.1:49152 \      # can also be a file
    --processes=5 \                 # number of worker processes
    --uid=1000 --gid=2000 \         # if root, uwsgi can drop privileges
    --harakiri=20 \                 # respawn processes taking more than 20 seconds
    --max-requests=5000 \           # respawn processes after serving 5000 requests
    --vacuum \                      # clear environment on exit
    --home=/path/to/virtual/env \   # optional path to a virtualenv
    --daemonize=/var/log/uwsgi/yourproject.log      # background the process

Another example stackoverflow.com/a/22610623

V
Veseloff, 2014-11-30
@Veseloff

What exactly doesn't work? Is the project itself okay? Runs via runserver? Does uwsgi start without errors if run via "uwsgi --ini"?

C
Cyrus, 2014-12-01
@Novakuz

Yes, everything works through runserver, I can’t run it through ini, as I understand it, I need to specify a flag in rc.conf so that when I start uwsgi it picks up my project ini?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question