update to nationwide standard

This commit is contained in:
welld1
2018-09-27 21:58:28 -04:00
parent 7eb5e57047
commit f111005cc2
5 changed files with 163 additions and 158 deletions

View File

@@ -1,64 +1,38 @@
# Django Installer for CentOS 7
## Quick Install
# Django Setup for CentOS 7
## Install
```bash
$ git clone https://gitlab.ducoterra.net/server/django_installer.git
$ cd django_installer
$ vim vars
vim vars
```
```bash
# django project settings
# django project settings
export user="centos" <---- set to your user (can use nginx)
export projectname="mysite" <---- set to your project name
# TODO:
# change hostname to an array:
# (hostname1.net hostname2.net hostname2.net)
export hostname="centos.duco.net" <---- set to your hostname (ip or domain)
export letsencrypt=False <---- not working yet
export user="" <-- give the user you want to own the site
export projectname="" <-- give your project a friendly name
export hostname="" <-- add your hostname (can be an IP address)
export usegit=False <-- if you have an existing project, set to True
export giturl="" <-- put the url for the git repo here
export gitkey="" <-- put the path to the ssh key git will use here
```
```bash
$ sudo ./install.sh
Installing dependencies
Installing gcc
Installing wget
Installing nginx
Installing libsqlite3x-devel.x86_64
Installing postgresql-server
Installing postgresql-devel
Installing postgresql-contrib
Installing bzip2-devel
Installing zlib-devel
Installing libffi-devel
Installing openssl-devel
Installing policycoreutils-python.x86_64
Installing Python
Configure
Make
Make altinstall
Upgrading pip
Installing virtualenv
Starting Django project
Creating venv
Installing django
Installing gunicorn
Installing psycopg2-binary
Starting django project
Collecting static
Making migrations
Migrating
Setting up gunicorn
Starting gunicorn
Enabling gunicorn at startup
Configuring Nginx
Starting nginx
Enabling nginx
Done!
$
sudo ./install.sh
```
Done!
## Reset
If anything goes wrong with the project and you don't want to perform a full uninstall:
```bash
sudo ./reset
```
will reset the project but leave the dependencies installed. You can rerun the installer with different variables to fix what was incorrect. WARNING: This will delete your project (including your database)
## Uninstall
To completely remove every trace of the project from your server:
```bash
sudo ./uninstall
```
This will completely remove everything.
## A more detailed explanation
### vars
```bash
@@ -111,7 +85,7 @@ In order for this script to work its magic you'll need a few packages provided b
```bash
# check if root
if [[ $EUID -ne 0 ]]; then
echo -e "This script must be run as root"
echo -e "This script must be run as root"
exit 1
fi
cd /root/
@@ -288,7 +262,7 @@ Next the script starts the Django project. You'll notice that the project struct
│ └── manage.py
└── venv/
```
When making changes to nginx or gunicorn it's important to keep this structure in mind. There are 3 folders called ```$projectname```.
When making changes to nginx or gunicorn it's important to keep this structure in mind. There are 3 folders called ```$projectname```.
After this, the script updates allowed hosts, collects static, and makes migrations.
@@ -337,4 +311,4 @@ if [ ! $user = "nginx" ] ; then
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf
fi
```
Which inserts the specified user (if not nginx) into nginx.conf. The script finishes by enabling gunicorn and nginx at startup.
Which inserts the specified user (if not nginx) into nginx.conf. The script finishes by enabling gunicorn and nginx at startup.