| Line 3: | Line 3: | ||
== Deployment steps == | == Deployment steps == | ||
| - | This instruction provides an overview of | + | This instruction provides an overview of deployment process of revs from the |
sources fetched from gitorious. The result of the deployment is fully functional | sources fetched from gitorious. The result of the deployment is fully functional | ||
tool ready to be used in production environment. | tool ready to be used in production environment. | ||
| - | === Install REVS from OBS repo ( | + | === Install REVS from OBS repo (preferred) === |
TODO: write sth. here | TODO: write sth. here | ||
| Line 78: | Line 78: | ||
</pre> | </pre> | ||
| + | |||
| + | |||
| + | == Customization == | ||
| + | |||
| + | The goal of this article is to provide a comprehensive instruction on how to deploy | ||
| + | several custom instances of REVS on the same machine. | ||
| + | |||
| + | === Components === | ||
| + | |||
| + | There are basically three things that are supposed to differ in each deployed | ||
| + | REVS instance. | ||
| + | |||
| + | # database | ||
| + | # settings describing the database | ||
| + | # namespace in REVS' root URL | ||
| + | |||
| + | There are also things that are designed to be shared between REVS instances. | ||
| + | |||
| + | # templates | ||
| + | # static files | ||
| + | # python code | ||
| + | |||
| + | === Configure custom REVS instance === | ||
| + | |||
| + | In the instruction below it is assumed that you followed deployment instruction | ||
| + | and installed the default apache & mysql configuration. In case if you decided | ||
| + | to install only revs and do web server and database configuration yourself, this | ||
| + | document is useless for you. | ||
| + | |||
| + | In order not to abstract too much, lets configure a blank REVS instance in | ||
| + | a namespace "ce". Below it is assumed that you invoke all commands as root. | ||
| + | |||
| + | The first thing that you have to do is to copy the default REVS settings.py into | ||
| + | something with a reasonable name. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | cp /etc/revs/settings.py /etc/revs/ce_settings.py | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Open the brand new file with you favorite text editor. It currently has the | ||
| + | following content. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | from revs.basesettings import * | ||
| + | |||
| + | FORCE_SCRIPT_NAME = "/revs" | ||
| + | |||
| + | DATABASES = { | ||
| + | 'default': { | ||
| + | 'ENGINE': 'django.db.backends.mysql', | ||
| + | 'NAME': 'revs', | ||
| + | 'USER': 'revs', | ||
| + | 'PASSWORD': 'revs', | ||
| + | 'HOST': '', | ||
| + | 'PORT': '' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | There are two things to change. First, '''FORCE_SCRIPT_NAME'''. It has to be equal | ||
| + | to the target namespace. It should start with slash and end without it. For more | ||
| + | information concerning '''FORCE_SCRIPT_NAME''' check official [https://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#force-script-name Django Docs]. | ||
| + | Second change database name so that new instance does not collide with the | ||
| + | already existing one. After these two modifications your settings shall look | ||
| + | like the ones below. Note, database user and password are not important thus for | ||
| + | the sake of simplicity lets leave them as they are. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | from revs.basesettings import * | ||
| + | |||
| + | FORCE_SCRIPT_NAME = "/ce" | ||
| + | |||
| + | DATABASES = { | ||
| + | 'default': { | ||
| + | 'ENGINE': 'django.db.backends.mysql', | ||
| + | 'NAME': 'ce', | ||
| + | 'USER': 'revs', | ||
| + | 'PASSWORD': 'revs', | ||
| + | 'HOST': '', | ||
| + | 'PORT': '' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | After you changed you settings please link them to '''/usr/share/pyshared/revs/'''. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | ln -s /etc/revs/ce_settings.py /usr/share/pyshared/revs/ | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Additionally you have to link your settings to all python versions that support | ||
| + | revs. It can be done using the following code snippet. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | SETTINGS_FILE=/usr/share/pyshared/revs/ce_settings.py | ||
| + | REVS_FOLDERS=/usr/lib/pymodules/python2.*/revs/ | ||
| + | |||
| + | for name in $REVS_FOLDERS | ||
| + | do | ||
| + | ln -s $SETTINGS_FILE $name | ||
| + | done | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Now you need to create a database for you brand new REVS instance. Run MySQL | ||
| + | client as a root user. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | mysql -u root -p | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | And execute the following SQL for '''ce''' database name specified in ce_settings. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | CREATE DATABASE IF NOT EXISTS ce CHARACTER SET utf8; | ||
| + | GRANT ALL ON ce.* TO 'revs'@'localhost' IDENTIFIED BY 'revs'; | ||
| + | FLUSH PRIVILEGES; | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Now initialize database structure in this database. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | python /usr/share/pyshared/revs/manage.py syncdb --settings=ce_settings --noinput | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | The command shall additionally create '''admin''' user with '''admin''' password for | ||
| + | you. | ||
| + | |||
| + | Now you need to configure the access to '''/ce''' namespace in browser. | ||
| + | |||
| + | Lets copy the wsgi script responsible for handling REVS instances. Call a new | ||
| + | script '''ce.wsgi''' for the sake of simplicity. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | cp /usr/share/revs/apache/revs.wsgi /usr/share/revs/apache/ce.wsgi | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | The script has the following code in it: | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | import os | ||
| + | import sys | ||
| + | |||
| + | os.environ['DJANGO_SETTINGS_MODULE'] = 'revs.settings' | ||
| + | import django.core.handlers.wsgi | ||
| + | application = django.core.handlers.wsgi.WSGIHandler() | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Change it to look like: | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | import os | ||
| + | import sys | ||
| + | |||
| + | os.environ['DJANGO_SETTINGS_MODULE'] = 'revs.ce_settings' | ||
| + | import django.core.handlers.wsgi | ||
| + | application = django.core.handlers.wsgi.WSGIHandler() | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Copy the default apache config. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | cp /etc/apache2/sites-available/revs /etc/apache2/sites-available/ce | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Open the new file with some text editor. It is supposed to have the following | ||
| + | content: | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | # Serve django views | ||
| + | WSGIScriptAlias /revs /usr/share/revs/apache/revs.wsgi | ||
| + | WSGIPassAuthorization On | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Replace '''/revs''' with '''/ce''' (correlates with the namespace) and '''revs.wsgi''' | ||
| + | with '''ce.wsgi'''. Eventually the file is supposed to look like the one below. | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | # Serve django views | ||
| + | WSGIScriptAlias /ce /usr/share/revs/apache/ce.wsgi | ||
| + | WSGIPassAuthorization On | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Enable the site and reload apache web server | ||
| + | |||
| + | <pre> | ||
| + | |||
| + | a2ensite ce | ||
| + | /etc/init.d/apache2 reload | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | Go to '''DOMAIN_NAME/ce''' in your browser and enjoy. | ||
Contents |
This instruction provides an overview of deployment process of revs from the sources fetched from gitorious. The result of the deployment is fully functional tool ready to be used in production environment.
TODO: write sth. here
Fetch package source from gitorious.
git clone git://gitorious.org/meego-infrastructure-tools/revs.git
Install all build dependencies.
sudo apt-get install yum python-django debhelper python-support python-setuptools python-sphinx python-sqlite
Build the package.
cd revs
dpkg-buildpackage -rfakeroot -uc -us -sa -tc -D
cd ..
Install REVS and REVS' lamp configuration binary dependencies
sudo apt-get install mysql-server apache2 libapache2-mod-wsgi python-mysqldb
Install REVS together with LAMP configuration. Note that revs itself has to be installed before LAMP configuration.
sudo dpkg -i revs_*.deb
sudo dpkg -i revs-lamp_*.deb
After installing REVS you may go to DOMAIN/revs to use the tool or to DOMAIN/revs/admin to access admin interface. The default admin user has username admin and password admin.
Populate database with the latest production data.
TODO: write sth. here
Install the participant to keep the database up to date.
TODO: write sth. here
The goal of this article is to provide a comprehensive instruction on how to deploy several custom instances of REVS on the same machine.
There are basically three things that are supposed to differ in each deployed REVS instance.
There are also things that are designed to be shared between REVS instances.
In the instruction below it is assumed that you followed deployment instruction and installed the default apache & mysql configuration. In case if you decided to install only revs and do web server and database configuration yourself, this document is useless for you.
In order not to abstract too much, lets configure a blank REVS instance in a namespace "ce". Below it is assumed that you invoke all commands as root.
The first thing that you have to do is to copy the default REVS settings.py into something with a reasonable name.
cp /etc/revs/settings.py /etc/revs/ce_settings.py
Open the brand new file with you favorite text editor. It currently has the following content.
from revs.basesettings import *
FORCE_SCRIPT_NAME = "/revs"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'revs',
'USER': 'revs',
'PASSWORD': 'revs',
'HOST': '',
'PORT': ''
}
}
There are two things to change. First, FORCE_SCRIPT_NAME. It has to be equal to the target namespace. It should start with slash and end without it. For more information concerning FORCE_SCRIPT_NAME check official Django Docs. Second change database name so that new instance does not collide with the already existing one. After these two modifications your settings shall look like the ones below. Note, database user and password are not important thus for the sake of simplicity lets leave them as they are.
from revs.basesettings import *
FORCE_SCRIPT_NAME = "/ce"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'ce',
'USER': 'revs',
'PASSWORD': 'revs',
'HOST': '',
'PORT': ''
}
}
After you changed you settings please link them to /usr/share/pyshared/revs/.
ln -s /etc/revs/ce_settings.py /usr/share/pyshared/revs/
Additionally you have to link your settings to all python versions that support revs. It can be done using the following code snippet.
SETTINGS_FILE=/usr/share/pyshared/revs/ce_settings.py
REVS_FOLDERS=/usr/lib/pymodules/python2.*/revs/
for name in $REVS_FOLDERS
do
ln -s $SETTINGS_FILE $name
done
Now you need to create a database for you brand new REVS instance. Run MySQL client as a root user.
mysql -u root -p
And execute the following SQL for ce database name specified in ce_settings.
CREATE DATABASE IF NOT EXISTS ce CHARACTER SET utf8;
GRANT ALL ON ce.* TO 'revs'@'localhost' IDENTIFIED BY 'revs';
FLUSH PRIVILEGES;
Now initialize database structure in this database.
python /usr/share/pyshared/revs/manage.py syncdb --settings=ce_settings --noinput
The command shall additionally create admin user with admin password for you.
Now you need to configure the access to /ce namespace in browser.
Lets copy the wsgi script responsible for handling REVS instances. Call a new script ce.wsgi for the sake of simplicity.
cp /usr/share/revs/apache/revs.wsgi /usr/share/revs/apache/ce.wsgi
The script has the following code in it:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'revs.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Change it to look like:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'revs.ce_settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Copy the default apache config.
cp /etc/apache2/sites-available/revs /etc/apache2/sites-available/ce
Open the new file with some text editor. It is supposed to have the following content:
# Serve django views
WSGIScriptAlias /revs /usr/share/revs/apache/revs.wsgi
WSGIPassAuthorization On
Replace /revs with /ce (correlates with the namespace) and revs.wsgi with ce.wsgi. Eventually the file is supposed to look like the one below.
# Serve django views
WSGIScriptAlias /ce /usr/share/revs/apache/ce.wsgi
WSGIPassAuthorization On
Enable the site and reload apache web server
a2ensite ce
/etc/init.d/apache2 reload
Go to DOMAIN_NAME/ce in your browser and enjoy.