-
Notifications
You must be signed in to change notification settings - Fork 3
DJ Installation
Get system-wide dependencies: (McStas/McXtrace is unlisted here, it needs to be installed using the normal guidelines from mcstas.org. MPI is also a requirement, for example openmpi.)
$ sudo apt-get install git
$ sudo apt-get install libopenmpi-dev
$ sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
$ sudo apt-get install python-virtualenv
$ sudo apt-get install makepasswd
$ sudo apt-get install nginx
If your system already includes a webserver like apache2, you may need to run the two following commands for a successful installation / configuration of nginx:
$ sudo update-rc.d apache2 remove
$ sudo service apache2 stop
Set up the virtual environment "mcvenv" and pip dependencies into it:
$ virtualenv mcvenv
$ source mcvenv/bin/activate
$ pip install -I Django==1.8.2
$ pip install simplejson django_auth_ldap uwsgi python-ldap
NOTE: You may have to sudo to build uwsgi, in which case you must use the absolute pip path (e.g. /srv/mcweb/mcvenv/bin/pip).
Download and install mcsimulator.
$ source mcvenv/bin/activate
$ git clone https://github.com/McStasMcXtrace/McWeb
$ cd McWeb
$ python manage.py migrate
$ python manage.py collect_instr
...or this for mcsimulator (legacy):
$ python manage.py syncdb
$ python manage.py generate_docs
$ ./scripts/update_instr.sh
Set user rights to www-data for everything:
$ sudo chown -R www-data:www-data mcvenv McWeb
$ sudo chmod -R g+w mcvenv McWeb
In McWeb/mcweb_uwsgi.ini
, change the paths in the to correspond to your setup (must be absolute).
Appropriately change the VIRTUALENV and DIR variable values in the file McWeb/scripts/uwsgi
. Create a symlink of this in /etc/init.d/
, e.g.:
$ ln -s /srv/mcweb/McWeb/scripts/uwsgi /etc/init.d/uwsgi_mcweb
Check that it works by running
$ sudo /etc/init.d/uwsgi_mcweb start
Install open ldap "slapd" and ldap-utils:
$ apt-get install slapd ldap-utils
When prompted for the ldap admin password, keep in mind that this is required to set up LDAP access. If you happen to lose the password, or if want to reset it, simply use:
$ dpkg-reconfigure slapd
The ldap database has to be set up and this is done by a Python script inlcuded with the mcstas simulator app. Go to the directory .../McWeb/ldifs/ and run:
$ python ldap_initdb.py <pw>
where pw is the ldap admin password.
Use the following to get mcsimulator online:
$ sudo /etc/init.d/uwsgi start/stop/status
$ sudo service nginx start/stop/status
NOTE: You must stop and start the webserver for changes to static content to take effect (and thus, after installing mcsimulator). You must also stop apache2, if it is running on your system (sudo service apache2 stop). Finally, please note that the entire path of folders containing the web app, all the way to "/", must have rx rights on them for www-data.
You shold be able to test the server at this point, using the super user your created at install time. You should also be able to use the admin site (/admin), but you may not be able to simulate until you have added users to groups (see below).
-
In the file .../McWeb/mcwww/settings.py, change the value of
AUTH_LDAP_USER_SEARCH
to conform to your ldap dn (the one you identified above). -
Notice the variable
AUTHENTICATION_BACKENDS
in the same file (settings.py). This contains two lines, one of which is out-commented. This should be the django model backend, and not the ldap backend. Please make sure the django model backend is disabled. Otherwise, LDAP auth will effectively be overridden by the local login.