-
Notifications
You must be signed in to change notification settings - Fork 9
Deployment
NOTE: The following is extremely out of date. We use Kubernetes now.
The following are some notes from deploying webolith on an AWS instance, as well as general setup info.
Here is my "pip freeze" file. It is recommended that you install pip, and use virtualenv to create a virtual environment for this installation. This currently has been tested and runs with Python 2.6.6 but I don't see why it wouldn't work for 2.7.
BeautifulSoup==3.2.0
Django==1.3
Fabric==1.2.0
Markdown==2.0.1
MySQL-python==1.2.3
South==0.7.3
cssmin==0.1.4
-e git://github.com/azuer88/django-basic-apps.git@c757ee207b4e699ddf2c4cd00bb495d9a3b65ca9#egg=django_basic_apps-dev
django-registration==0.8
django-tagging==0.3.1
gunicorn==0.13.4
paramiko==1.7.7.1
pycrypto==2.3
python-dateutil==2.0
recaptcha-client==1.0.6
webassets==0.5
wsgiref==0.1.2
redis==2.7.2
Almost all of the above packages can be installed with pip install Django==1.3 (for example), EXCEPT for the following:
-
MySQL-python might give you some problems if you're on a Mac, but hopefully not. I think your Python and MySQL installations should have the same architecture (32 or 64 bit). If they don't, you might have to do some lipo nonsense. (http://stackoverflow.com/questions/2088569/how-do-i-force-python-to-be-32-bit-on-snow-leopard-and-other-32-bit-64-bit-questi/3059113#3059113) Also, if it doesn't install with pip you might have to install from source and change the site.cfg file to point at your mysql_config.
mysql_config = /usr/local/mysql/bin/mysql_config # in my case
- MySQL (yum install mysql). Create a user and a database named djAerolith and grant access to user for this database:
create user 'aerolith'@'localhost' identified by 'password';
grant all privileges on djAerolith.* to 'aerolith'@'localhost' with grant option;
- If need to restore from a sql backup:
mysql -u aerolith -p djAerolith < backup.sql
- dbCreator needs Qt (4.7+, probably lower will work) to create the MySQL alphagram/word/lexicon "dump" files that can be loaded in with LOAD DATA INFILE. I will probably host these too in the future.
Make sure to do a python manage.py syncdb
and a python manage.py migrate app
for each South-controlled app if this is a new code installation. app
should be replaced with wordwalls
, accounts
, and tablegame
right now.
nginx, gunicorn:
http://ericholscher.com/blog/2010/aug/16/lessons-learned-dash-easy-django-deployment/
python manage.py run_gunicorn --config ../gunicornConf.py --daemon
-
kill -HUP `cat /home/ec2-user/webolith/gunicorn.pid`
to reload new configuration/new code
sudo yum install nginx (or another way of installing nginx. you don't need nginx unless you are deploying to a web server -- for local testing, gunicorn or even Django's manage.py runserver is fine)
nginx start: sudo /etc/init.d/nginx start
conf file is at /etc/nginx/nginx.conf
to restart:
find pid of nginx master and send -HUP to it
sudo kill -HUP `cat /var/run/nginx.pid`
my nginx conf file:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
accept_mutex off; # on if worker_rpocesses > 1
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.nginx.org/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream app_server {
server 127.0.0.1:8000 fail_timeout=0;
}
server {
listen 80;
server_name .aerolith.org;
#charset koi8-r;
#access_log logs/host.access.log main;
#root /home/ec2-user/webolith_static;
location /static/ {
# check for static file, if not found proxy to app
alias /home/ubuntu/webolith_static/;
# try_files $uri @proxy_to_app;
}
location /lists {
alias /home/ubuntu/public_html/lists;
autoindex on;
}
location /favicon.ico {
alias /home/ubuntu/favicon.ico;
}
location / {
try_files $uri @proxy_to_app;
}
# location /static/
# {
# }
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#proxy_buffering off;
proxy_pass http://app_server;
}
}
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
}