Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active October 14, 2017 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jniltinho/6cddcfdb306af6cfbbe55ccb106a92a8 to your computer and use it in GitHub Desktop.
Save jniltinho/6cddcfdb306af6cfbbe55ccb106a92a8 to your computer and use it in GitHub Desktop.
Create Django Skeleton
#!/bin/bash
### Create Django Skeleton APP on Debian|Ubuntu
## First install:
## apt-get -y install python-django
## Default folder
mkdir /var/www
cd /var/www
## Create Project
django-admin startproject mysite
## Create APP
django-admin startapp hello
cd mysite
mkdir logs
mkdir hello/templates
wget https://gist.githubusercontent.com/jniltinho/27fd1e7c5fc8f3a230992db2b9cef836/raw/679a7c2befce34a6367cdd29ee1f84d74e03b80e/django_index_html -O hello/templates/index.html
echo "from django.shortcuts import render
# Create your views here.
def index(request):
return render(request, 'index.html', {})
"> hello/views.py
echo "from django.conf.urls import include, url
from . import views
urlpatterns = [
url(r'^$', views.index),
]
" >hello/urls.py
sed -i "s|'django.contrib.staticfiles',|'django.contrib.staticfiles','hello',|" mysite/settings.py
echo "from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('hello.urls')),
]
"> mysite/urls.py
python manage.py migrate
python manage.py runserver
### Usando uWSGI na app Django
## apt-get -y install python-dev python-pip
## pip install uwsgi
## chown -R www-data:www-data /var/www
#uwsgi --chdir=/var/www/projeto/mysite --module=mysite.wsgi:application --env DJANGO_SETTINGS_MODULE=mysite.settings
# --socket=:8001 --processes=5 \
# --master --pidfile=/var/www/projeto/mysite/logs/mysite.pid --harakiri=20 --max-requests=5000 \
# --protocol=http --uid=www-data --gid=www-data
#uwsgi --chdir=/var/www/projeto/mysite --module=mysite.wsgi:application --env DJANGO_SETTINGS_MODULE=mysite.settings \
# --processes=5 \
# --master --pidfile=/var/www/projeto/mysite/logs/mysite.pid --harakiri=20 --max-requests=5000 \
# --socket=/var/www/projeto/mysite/mysite.sock --chmod-socket=664 --uid=www-data --gid=www-data \
# --daemonize=/var/www/projeto/mysite/logs/mysite.log
## Stop uWSGI
## uwsgi --stop /var/www/projeto/mysite/logs/mysite.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment