citmusa
9/10/2014 - 1:47 AM

alwaysdata django app deploy

alwaysdata django app deploy

############################
### settings.production.py
############################

ALLOWED_HOSTS = ['user.alwaysdata.net']                                 
 
DEBUG = True
TEMPLATE_DEBUG = DEBUG
 
PROJECT_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', '..')
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
 
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'public', 'static')
STATIC_URL = '/static/' if DEBUG else 'http://user.alwaysdata.net/static/'
STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT, 'static'),
)
 
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'HOST': 'mysql1.alwaysdata.com',
        'NAME': 'dbname',
        'USER': '96608',
        'PASSWORD': 'password',
    }
}
##########################
### django.fcgi
### /(manage.py dir)/public
##########################

# python bin path in virtual env
#!/nfs/http7/changodjango/vjean/bin/python 
import os, sys
 
venv = '/nfs/http7/changodjango/vjean/bin/activate_this.py'
execfile(venv, dict(__file__=venv))
 
_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, _PROJECT_DIR)
sys.path.insert(0, os.path.dirname(_PROJECT_DIR))
 
_PROJECT_NAME = _PROJECT_DIR.split('/')[-1]
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings.production" % _PROJECT_NAME
 
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
##########################
### .htaccess
### /(manage.py dir)/public
##########################

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]