setup askbot on beanstalk
$ mkdir askbot_on_bs
$ cd askbot_on_bs
$ git init .
create .gignore and add the following: .pyc AWS-ElasticBeanstalk-CLI bin/ lib/ man/ src/ include/ debug.sqlite
$ git add .
$ git ci -m"initial gitignore"
$ virtualenv .
$ source bin/activate
$ pip install Django==1.4.5 mysql-python
$ pip install -e git+git://github.com/ASKBOT/askbot-devel.git#egg=askbot
$ askbot-setup
-> choose 'mysite' as directory. choose mysql and name DB all to 'none', we'll be replacing it in just a second
$ git add .
$ git ci -m"intial askbot setup"
Open settings.py and replace the Database setup with:
if LIVE:
DATABASE_OPTIONS = {'init_command': 'SET storage_engine = MyISAM'}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USERNAME'],
'PASSWORD': os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT': os.environ['RDS_PORT'],
"OPTIONS": {
'init_command': 'SET storage_engine = MyISAM'
}
}
}
else:
DEBUG = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'debug.sqlite'
}
}
And you probably also want to set DEBUG = False
on top (it is automatically re-activated with the database setup on non Beanstalk as you can see)
$ python manage.py syncdb
$ python manage.py migrate
$ python manage.py runserver
And then check at http://localhost:8000/ if it worked.
(if any of those give you a 'str_to_unicode'-error, you unintentionally installed django 1.5 - uninstall it and reinstall django 1.4.5 , see http://askbot.org/en/question/10016/error-importerror-cannot-import-name-str_to_unicode/)
$ git add .
$ git ci -m"intial askbot configuration"
$ pip freeze > requirements.txt
Open the file and make sure the the line for askbot looks like this (you probably have to replace it): -e git+git://github.com/ASKBOT/askbot-devel.git#egg=askbot
note: this applies to askbot <= 0.7.48 because there is a bug in those which do not let us migrate the database on the mysql-systems beanstalk will be setting up for us.
$ git add requirements.txt
$ git ci -m"add requirements"
The default django.wsi doesn't have our devel in there. So open the file and replace the content with:
import os
import sys
current_directory = os.path.dirname(__file__)
parent_directory = os.path.dirname(current_directory)
module_name = os.path.basename(current_directory)
sys.path.append(parent_directory)
sys.path.append(os.path.join(parent_directory, 'src'))
sys.path.append(current_directory)
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % module_name
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
$ wget https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.2.zip
$ unzip AWS-ElasticBeanstalk-CLI-2.2.zip
$ ln -s ../AWS-ElasticBeanstalk-CLI-2.2/eb/linux/python2.7/eb bin/eb
$ eb init
-> follow setup as described unter "to configure AWS elastic bean" at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
$ eb start
that might takes a while ...
open .elasticbeanstalk/askbot.config (attached) and change the setup as follows:
packages:
yum:
git: []
container_commands:
001_collectstatic:
command: "python mysite/manage.py collectstatic --noinput"
01_syncdb:
command: "python mysite/manage.py syncdb --noinput"
leader_only: true
03_migrate:
command: "python mysite/manage.py migrate "
leader_only: true
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: mysite/django.wsgi
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/" : "mysite/static/"
"aws:elasticbeanstalk:application:environment":
"DJANGO_SETTINGS_MODULE": "settings"
$ git add .
$ git ci -m"intial askbot aws configuration"
To deploy on aws we can use git directly:
$ git aws.push
- Coming soon