Skip to main content

Django Ubuntu Deployer

This is a simple package for deploying django projects on ubuntu server 16.04 or latest.

Does what is written in article How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 16.04 | DigitalOcean.

In Ubuntu Server

ubuntu@server:~# cd /home/
ubuntu@server:/home# sudo apt-get update
ubuntu@server:/home# sudo apt-get install python3-pip python3-dev libpq-dev nginx
Install virtualenv for creating virtual environment:
ubuntu@server:/home# pip3 install virtualenv
Create project folder and enter in:
ubuntu@server:/home# mkdir project && cd project
Create virtual environment and activate:
ubuntu@server:/home/project# virtualenv venv
ubuntu@server:/home/project# source venv/bin/activate
Install Django, django_ubuntu_deployer and gunicorn
(venv)ubuntu@server:/home/project# pip install django django_ubuntu_deployer gunicorn
Register django_ubuntu_deployer in INSTALLED_APPS
INSTALLED_APPS = [
    ...,
    'ubuntu_deployer',
]
Add domains to ALLOWED_HOSTS:
ALLOWED_HOSTS = [
    'your domain 1',
    ...,
    'your domain n',
]
Collectstatic files:
(venv)ubuntu@server:/home/project# python manage.py collectstatic
Now deploy your APP in Ubuntu Server (use for this username and password):
(venv)ubuntu@server:/home/project# python manage.py deploy

Or restart server

(venv)ubuntu@server:/home/project# python manage.py deploy --restart

Configure gunicorn, nginx and virtual environment folder

In your settings.py:
DJANGO_UBUNTU_DEPLOYER = {
    # gunicorn config
    # required in gunicorn config {user}, {path}, {gunicorn}, {sock}, {name}
    'GUNICORN_CONFIG': """
Description=gunicorn daemon
After=network.target

[Service]
User={user}
Group=www-data
WorkingDirectory={path}
ExecStart={gunicorn} --access-logfile - --workers 3 --bind unix:{sock} {name}.wsgi:application

[Install]
WantedBy=multi-user.target
    """,

    # nginx config
    # required in nginx config {domains}, {static}, {media}, {path}, {sock}, {extras}
    'NGINX_CONFIG': """
server {{
    listen 80;
    server_name {domains};

    location = /favicon.ico {{ access_log off; log_not_found off; }}

    location {static} {{
        root {path};
    }}

    location {media} {{
        root {path};
    }}

    location / {{
        include proxy_params;
        proxy_pass http://unix:{sock};
    }}

    {extras}
}}
    """,

    # nginx_config extras
    'NGINX_EXTRAS': '',
}

Metadata

Release files for django-ubuntu-deployer 4.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ubuntu-deployer 4.3.0
File Size Uploaded Provenance Actions
django_ubuntu_deployer-4.3.0.tar.gz 4.3 kB Without provenance Details for django_ubuntu_deployer-4.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-ubuntu-deployer 4.3.0
File Interpreter ABI Platform Actions
django_ubuntu_deployer-4.3.0-py3-none-any.whl Python 3 none any Details for django_ubuntu_deployer-4.3.0-py3-none-any.whl

Total release size: 10.3 kB

Release files / django_ubuntu_deployer-4.3.0.tar.gz

Download URL django_ubuntu_deployer-4.3.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ce3ce12ed7a5ea6256b707af0df5742e122f3c0a5410af5d4b667e6f0d959cc4
BLAKE2b-256 checksum
How to use checksums
344a14a635c250174404f3d4c6885daafd30250c99bbd266c0b697c01db44fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Release files / django_ubuntu_deployer-4.3.0-py3-none-any.whl

Download URL django_ubuntu_deployer-4.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27314e1d885c0cdcfe08e0f963d9501bcf1d83255b073e75d1f8d8d476cb7746
BLAKE2b-256 checksum
How to use checksums
8ac689c8220838cad4b833894578e20be244cfc802a503a86823770ecfcb8554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Security for django-ubuntu-deployer 4.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page