GithubHelp home page GithubHelp logo

mrb101 / django-auto-deploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jdbit/django-auto-deploy

0.0 0.0 0.0 2.28 MB

Deploy multiple Django websites just in one click (Nginx, Gunicorn, MySQL)

License: GNU General Public License v3.0

Shell 100.00%

django-auto-deploy's Introduction

Deploy as many Django websites as you want with one simple command

This script allows you to set up multiple Django websites easily. It automatically installs all the necessary dependencies (Nginx, Gunicorn, MySQL, Django MySQL connector) on your Ubuntu server, prepares a python virtual environment, and configure the MySQL database. Just by typing one command in the command line, you get the fully working Django website with a configured database (MySQL).

demo

Features and what is this script doing

  1. Generate SFTP/MySQL passwords
  2. Create a working directory in /var/www/$SITENAME
  3. Create a new Linux user and add it to the sftp group
  4. Assign user permissions to the working directory
  5. Install necessary dependencies: nginx, python3-pip, mysql-server, virtualenv, gunicorn, django, mysql-connector-python
  6. Create a new Django project, database, and configure Django to work with the MySQL database
  7. Create NGINX and Gunicorn config files (a separate config file for each site)
  8. Save passwords to pass.txt and create .gitignore file

Installation & Usage

Execute this command on your server:

curl -o addsite https://raw.githubusercontent.com/jdbit/django-auto-deploy/master/addsite && chmod +x addsite && sudo ./addsite

This command will clone the script to the current directory, make it executable, and execute with root privileges.

You just need to enter the desired website and domain name when requested and your website is ready to use! If you want to add another website, just run the sudo ./addsite again.

All the sites will be placed to /var/www/{SITENAME} directory. Before running the script, make sure there is no folder in /var/www named as the site you are going to create.

Installation logs

In the working directory /var/www/$SITENAME a log file will be created:

  • deploy.log - all the bash script output will be saved to this file, you can check it to ensure there were no errors during the installation process

The script creates Python virtual environment in /var/www/{SITENAME}/env directory, you can activate the virtual environment by this command:

source env/bin/activate

and exit from the python virtual environment with this command:

deactivate

You can set up as many Django websites as you want with this script.

The script creates a new MySQL database, a new DB user, and adds the necessary DB settings to DATABASES dict in settings.py.

Warning

Use the script on your own risk. It was tested only with fresh Ubuntu 20.04 Server installation. If you run it on your already configured server, there might be conflicts with other software installed.

Django hosting recommendation

If you need a good and affordable hosting for your Django projects, I would recommend DigitalOcean (get $100 in credit for 60 days through my referral link), you can run a few simple Django websites on a single virtual server just for 5$/month. I've tested it on the latest Ubuntu Server 20.04 installed on DigitalOcean 5$/month droplet.

django-auto-deploy's People

Contributors

jdbit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.