-
Notifications
You must be signed in to change notification settings - Fork 0
How to Install CKAN 2.0 from source on Ubuntu 12.04 on EC2
-
Note: To use the default Amazon EC2 Public DNS, replace “[yoursite.com]” with anything you like.
Launch a new EC2 instance with Ubuntu 12.04.
Create a new security group with 0.0.0.0 permissions on ports 22, 80, and 5000.
Download the resulting key.pem file to your local machine.
cd /directory/with/your.pem chmod 0600 "your.pem"
Add your key so you don’t have to type it in each time:
ssh-add your.pem
SSH to your instance
ssh ubuntu@XX-XXX-XXX-XXXX.compute-1.amazonaws.com
If you don’t want to add your key, use the following to connect to your instance:
ssh -i your.pem [email protected]
Once SSHed into your instance:
sudo aptitude update sudo aptitude install apache2 libapache2-mod-wsgi
Create a “servername.conf” file:
sudo nano /etc/apache2/conf.d/servername.conf
Include the following line in this servername.conf file:
ServerName REPLACEMEWITHANYTHINGYOULIKE
Restart Apache
sudo service apache2 restart
Create a folder for your CKAN website:
cd ~ mkdir public_html mkdir public_html/[yoursite.com] sudo chmod -R a+rX ~/public_html sudo chmod a+rx ~
Install Python and other dependencies:
sudo apt-get install python-dev postgresql libpq-dev python-pip python-virtualenv git-core solr-jetty openjdk-6-jdk python-pastescript cd ~/public_html/[yoursite.com]/ virtualenv --no-site-packages pyenv . pyenv/bin/activate pip install -e 'git+https://github.com/okfn/ckan.git#egg=ckan' pip install -r pyenv/src/ckan/pip-requirements.txt pip install Pylons deactivate . pyenv/bin/activate
sudo -u postgres createuser -S -D -R -P ckanuser pass pass sudo -u postgres createdb -O ckanuser ckan_dev -E utf-8
cd pyenv/src/ckan paster make-config ckan development.ini
sudo nano development.ini
Update the following lines:
host = 0.0.0.0 ckan.site_url = http://XX-XXX-XXX-XXXX.compute-1.amazonaws.com ckan.site_id = http://XX-XXX-XXX-XXXX.compute-1.amazonaws.com solr_url = http://XX-XXX-XXX-XXXX.compute-1.amazonaws.com:8080/solr
Exit the pyenv environment
deactivate
sudo nano /etc/default/jetty
Update the following lines:
NO_START=0 JETTY_HOST=0.0.0.0 JETTY_PORT=8080 JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64/ sudo service jetty start sudo mv /etc/solr/conf/schema.xml /etc/solr/conf/schema.xml.bak sudo ln -s /home/ubuntu/public_html/[yoursite.com]/pyenv/src/ckan/ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml sudo /etc/init.d/jetty stop sudo /etc/init.d/jetty start
. pyenv/bin/activate cd ~/public_html/[yoursite.com]/pyenv/src/ckan/ paster --plugin=ckan db init
cd ~/public_html/[yoursite.com]/pyenv/bin sudo nano mothership.py
Put this in the file:
import os instance_dir = '/home/ubuntu/public_html/[yoursite.com]' config_file = '/home/ubuntu/public_html/[yoursite.com]/pyenv/src/ckan/development.ini' pyenv_bin_dir = os.path.join(instance_dir, 'pyenv', 'bin') activate_this = os.path.join(pyenv_bin_dir, 'activate_this.py') execfile(activate_this, dict(__file__=activate_this)) from paste.deploy import loadapp config_filepath = os.path.join(instance_dir, config_file) from paste.script.util.logging_config import fileConfig fileConfig(config_filepath) application = loadapp('config:%s' % config_filepath)
cd /etc/apache2/sites-available
To use your default EC2 Public DNS URL:
sudo nano default
OR to use custom DNS:
cp default yoursite.com sudo nano yoursite.com
Add these lines:
WSGIScriptAlias / /home/ubuntu/public_html/[yoursite.com]/pyenv/bin/mothership.py WSGIPassAuthorization On ErrorLog /var/log/apache2/[yoursite.com].error.log CustomLog /var/log/apache2/[yoursite.com].custom.log combined
Make directories:
cd ~/public_html/[yoursite.com]/pyenv/src/ckan/ mkdir data sstore chmod g+w -R data sstore sudo chgrp -R www-data data sstore
Update development.ini to use the right log files:
sudo nano ~/public_html/[yoursite.com]/pyenv/src/ckan/development.ini
Change
args = ("ckan.log", "a", 20000000, 9)
to
args = ("/var/log/ckan/[yoursite.com]/ckan.log", "a", 20000000, 9)
Actually make these directories:
sudo mkdir -p /var/log/ckan/[yoursite.com] sudo chown www-data /var/log/ckan/[yoursite.com]
Enable your custom domain (do NOT do this if you are using the default DNS):
sudo a2ensite [yoursite.com]
Restart Apache:
sudo /etc/init.d/apache2 restart
sudo -s cd ~/public_html/[yoursite.com] . pyenv/bin/activate cd pyenv/src/ckan paster user add admin [email protected] paster sysadmin add admin