Skip to content

Instantly share code, notes, and snippets.

@alexander-ae
Last active August 29, 2015 14:06
Show Gist options
  • Save alexander-ae/c3c196a8123a2442dda3 to your computer and use it in GitHub Desktop.
Save alexander-ae/c3c196a8123a2442dda3 to your computer and use it in GitHub Desktop.
Configuración de django + apache
*/5 * * * * source ~/.bashrc && ~/webapps/django_1_5/apache2/bin/start
ServerRoot "/home/{user}/webapps/proyectos_1_5/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/{user}/logs/user/access_proyectos_1_5.log combined
ErrorLog /home/{user}/logs/user/error_proyectos_1_5.log
KeepAlive Off
Listen {port}
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 20
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
ServerAdmin desarrollo@staffcreativa.com
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
NameVirtualHost *:{port}
# Logging
LogLevel warn
<Directory /home/{user}/webapps/proyectos_1_5/>
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:{port}>
ServerName web.pe
ServerAlias web.pe
KeepAlive On
KeepAliveTimeout 2
WSGIDaemonProcess {web} processes=4 threads=5 inactivity-timeout=60 display-name=[wsgi-web]
WSGIProcessGroup web.pe
WSGIScriptAlias / /home/{user}/webapps/proyectos_1_5/{proyect}/src/settings/wsgi.py
</VirtualHost>
{
"DB_NAME": "",
"DB_USER": "",
"DB_PASSWORD": "",
"URL_SITE": "http://127.0.0.1:8000",
"SECRET_KEY": "my_super_secret_key",
"EMAIL_HOST": "",
"EMAIL_HOST_USER": "",
"EMAIL_HOST_PASSWORD": "",
"DEFAULT_FROM_EMAIL": "",
"SERVER_EMAIL": "",
"WORKON_HOME": "/home/username/.envs/",
"ENV": "django_1_5"
}
import json
import os
import sys
from os.path import dirname, realpath, join
from site import addsitedir
# directorio del proyecto
SITE_ROOT = dirname(realpath(__file__))
with open(join(SITE_ROOT, 'settings/settings.json')) as f:
ENV = json.load(f)
# entorno virtual
env = ENV['ENV']
if env:
WORKON_HOME = ENV['WORKON_HOME']
addsitedir('{0}/{1}/lib/python2.7/site-packages'.format(WORKON_HOME, ENV))
sys.path = [SITE_ROOT] + sys.path
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings.production')
# activamos el entorno virtual
if env:
activate_this = os.path.expanduser(
'{0}/{1}/bin/activate_this.py'.format(WORKON_HOME, env))
execfile(activate_this, dict(__file__=activate_this))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment