...
Consume the recently produces JSON files with the NORDUni consume scripts.
Install Neo4j graph database
Neo4j 1.5 embedded with Python bindings (recommended)
Install JPype and Neo4j-embedded.
Download jpype. (http://sourceforge.net/projects/jpype/files/)
Code Block |
---|
pip install neo4j-embedded export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/jre/ pip install /path/to/jpype-version.zip |
Neo4j 1.3 REST stand alone server
Download neo4j-1.3 from http://neo4j.org.
Extract the file to, for example, /var/opt/norduni/dependencies/.
Code Block |
---|
cd /var/opt/norduni/dependencies/
tar xfz neo4j-1.3.tar.gz
|
Copy the startup script from /var/opt/norduni/src/scripts/neo4j/ to /etc/init.d/ and then make neo4j start on boot.
Code Block |
---|
update-rc.d /et/init.d/neo4j defaults
|
You need to shut down port 7474 from anything except localhost.
Code Block |
---|
iptables -A INPUT -p tcp --dport 7474 -s localhost -j ACCEPT
iptables -A INPUT -p tcp --dport 7474 -j DROP
|
Save the rules and add the following line to your interface configuration so you will restore the rules on a reboot.
Code Block |
---|
bash -c "iptables-save > /etc/iptables.rules"
vi /etc/network/interfaces
iface eth0 inet static
pre-up iptables-restore < /etc/iptables.rules
|
Old Apache stuff
Configure the web server to play nice with neo4j-embedded. Install apache2-mpm-prefork libapache2-mod-wsgi.
Create a file name niweb in /etc/apache2/conf.d/.
Setting up old NOCLook version.
Code Block |
---|
sudo apt-get install apache2 libapache2-mod-wsgi git-core python-virtualenv postfix openjdk-6-jre-headless postgresql python-psycopg2 libpq-dev python-dev
|
Make a virtual python environment.
Code Block |
---|
cd /opt/python_environments/
sudo virtualenv --no-site-packages norduni
|
Install needed python modules.
Code Block |
---|
sudo su
source python_environments/norduni/bin/activate
pip install django ipaddr argparse pexpect markdown psycopg2 lucene-querybuilder gunicorn
|
Add the following python modules if you are running the Neo4j stand alone server:
Code Block |
---|
pip install httplib2
|
Get the NORDUni files:
Code Block |
---|
cd /var/opt/
git clone git://git.nordu.net/norduni.git
git checkout operation
|
Get the NERDS files:
Code Block |
---|
mkdir /opt/norduni/tools/
cd /opt/norduni/tools/
git clone https://github.com/fredrikt/nerds.git
|
Symlink admin media and the virtual python environment to niweb.
Code Block |
---|
cd |
Code Block |
WSGIPythonPath "/var/opt/norduni/src:/var/opt/norduni/src/niweb" WSGIPythonHome "niweb/ ln -s /var/opt/python_environments/norduni"/ env WSGIDaemonProcess processes=1 threads=25 # For neo4j-embedded WSGIApplicationGroup %{GLOBAL} # For neo4j-embedded WSGIRestrictStdin Off WSGIRestrictStdout Off WSGIScriptAlias / /var/opt/norduni/niweb.wsgi |
Add niweb path to niweb.wsgi
cd static
ln -s ../env/lib/python2.6/site-packages/django/contrib/admin/media/ admin
|
Set password for database user and create a new database
Code Block |
---|
sudo -u postgres psql postgres
\password postgres
Write password
Write password again
Ctrl+D
sudo -u postgres createdb norduni
|
Change the django settings.
Code Block |
---|
# Django settings for niweb project
cd /opt/norduni/src/niweb/
cp generic_settings.py settings.py
vi settings.py
|
Change at least the following settings.
Code Block |
---|
NIWEB_ROOT = |
Code Block |
sys.path.append('/opt/norduni/src/niweb/') |
/etc/apache2.conf
Code Block |
---|
<IfModule mpm_prefork_module> StartServers NIWEB_MEDIA_URL = '/static/' # Database settings DATABASES = { 'default': { 1 'ENGINE': 'django.db.backends.postgresql_psycopg2', ServerLimit 'NAME': 'norduni', 1 MinSpareServers 'USER': 'postgres', 5 MaxSpareServers 10'PASSWORD': 'secret', MaxClients 'HOST': 'localhost' } } # Neo4j 1 MaxRequestsPerChild 0 </IfModule> |
Add the following lines to /etc/apache2/sites-available/default-ssl
settings
NEO4J_RESOURCE_URI = 'http://localhost:7474/db/data/'
|
Comment out the static media url in /opt/norduni/src/niweb/urls.py.
Code Block | ||
---|---|---|
| ||
# Static serve
#(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.STATIC_DEV_MEDIA}),
|
Create a file name niweb in /etc/apache2/conf.d/.
Code Block |
---|
WSGIPythonPath "/var/opt/norduni/src:/var/opt/norduni/src/niweb"
WSGIPythonHome "/opt/python_environments/norduni"
WSGIRestrictStdin Off
WSGIRestrictStdout Off
WSGIScriptAlias / /var/opt/norduni/niweb.wsgi
|
Add niweb path to niweb.wsgi
Code Block |
---|
sys.path.append('/opt/norduni/src/niweb')
|
Add the following lines to /etc/apache2/sites-available/default-ssl
Code Block |
---|
Alias /admin_media /var/opt/norduni/src/niweb/static/admin/
Alias /site_media /var/opt/norduni/src/niweb/static/
<LocationMatch "^/(admin_media|site_media)">
Options FollowSymLinks
Order allow,deny
allow from all
SetHandler None
</LocationMatch>
|
Neo4j 1.3 REST stand alone server
Download neo4j-1.3 from http://neo4j.org.
Extract the file to, for example, /var/opt/norduni/dependencies/.
Code Block |
---|
cd /var/opt/norduni/dependencies/
tar xfz neo4j-1.3.tar.gz
|
Copy the startup script from /var/opt/norduni/src/scripts/neo4j/ to /etc/init.d/ and then make neo4j start on boot.
Code Block |
---|
update-rc.d /etc/init.d/neo4j defaults
|
You need to shut down port 7474 from anything except localhost.
Code Block |
---|
iptables -A INPUT -p tcp --dport 7474 -s localhost -j ACCEPT
iptables -A INPUT -p tcp --dport 7474 -j DROP
|
Save the rules and add the following line to your interface configuration so you will restore the rules on a reboot.
Code Block |
---|
bash -c "iptables-save > /etc/iptables.rules"
vi /etc/network/interfaces
iface eth0 inet static
pre-up iptables-restore < /etc/iptables.rules
|
Apache configuration for neo4j-embedded
If you want to run the latest version if NOCLook (using neo4j-embedded) you have to configure Apache to only use one process to run the Django code.
Install apache2-mpm-prefork and libapache2-mod-wsgi.
Create a file name niweb in /etc/apache2/conf.d/.
Code Block |
---|
WSGIPythonPath "/var/opt/norduni/src:/var/opt/norduni/src/niweb"
WSGIPythonHome "/opt/python_environments/norduni"
WSGIDaemonProcess processes=1 threads=25 # For neo4j-embedded
WSGIApplicationGroup %{GLOBAL} |
Code Block |
<LocationMatch "Shibboleth.sso"> SetHandler None # For neo4j-embedded WSGIRestrictStdin Off WSGIRestrictStdout Off WSGIScriptAlias / /var/opt/norduni/niweb.wsgi |
Add niweb path to niweb.wsgi
Code Block |
---|
sys.path.append('/opt/norduni/src/niweb')
|
/etc/apache2.conf
Code Block |
---|
<IfModule mpm_prefork_module> StartServers </LocationMatch> <Location "/accounts/login-federated/"> AuthType shibboleth 1 ServerLimit ShibRequireSession On require valid-user 1 MinSpareServers 5 RequestHeader set X_REMOTE_USER %{eppn}e MaxSpareServers 10 MaxClients RequestHeader set EPPN %{eppn}e 1 RequestHeaderMaxRequestsPerChild set 0 </IfModule> |
Apache Shibboleth configuration
Code Block |
---|
GIVENNAME %{givenName}e <LocationMatch "Shibboleth.sso"> RequestHeader set SN %{sn}e SetHandler None RequestHeader set MAIL %{mail}e </LocationMatch> <Location "/accounts/login-federated/"> RequestHeader set AFFILIATION %{affiliation}e AuthType shibboleth ShibRequireSession On RequestHeader set ENTITLEMENT %{entitlement}e </Location> require valid-user Alias /admin_media /var/opt/norduni/src/niweb/static/admin/ RequestHeader set X_REMOTE_USER %{eppn}e RequestHeader Alias /site_media /var/opt/norduni/src/niweb/static/ set EPPN %{eppn}e RequestHeader set <LocationMatch "^/(admin_media|site_media)"> GIVENNAME %{givenName}e RequestHeader set Options FollowSymLinksSN %{sn}e Order allow,denyRequestHeader set MAIL %{mail}e allow from all RequestHeader set AFFILIATION %{affiliation}e RequestHeader set SetHandler NoneENTITLEMENT %{entitlement}e </LocationMatch>Location> |