Mayan-EDMS in a virtual environment on Ubuntu 14.04
While looking for a document management system for a hospital, I stumbled across Mayan-EDMS and thought it would be worth investigating. I followed the installation instructions (which highly recommended a Python “virtual environment”) and had the package up and running in a relatively short time using the “runserver” command. Once I thought it might be worth a multi-user trial, I decided to replace the “runserver” environment with integration into Apache 2 on Ubuntu. I soon found that there were many ways to install Mayan-EDMS under Apache 2. Many of the methods did not seem to use the virtual environments that were suggested in the original setups. Furthermore, I was having a hard time making the instructions for installing in Apache 2 “jibe” with the configuration that existed on my system. For example, many of the methods used directories like “/var/www/django/mayan”. I had installed the Mayan-EDMS virtual environment in “/opt/mayan”. As such, my “site-packages” directory was at “/opt/mayan/lib/python2.7/site-packages”. Additionally, there were references to ‘manage.py’. For example, I was to told to execute “./manage.py collectstatic” to make the static files available for the webserver. “./manage.py” for me returned ‘manage.py: command not found”. When I searched for a file “manage.py”, I found one in /opt/mayan/venv/lib/python2.7/site-packages/django/conf/project_template/manage.py”, but when I would try to execute this program (with “collectstatic” as an argument, I would get screens full of errors and a rather cryptic message about settings. After a lot of experimentation and debugging, I managed to get Mayan-EDMS running fairly well from within Apache. In the hopes that my experience can help others with similar problems, I am going to detail the process that I followed in the hopes that some other person doesn’t have to go through the frustration that I did. I make no claims about whether this will work for you or whether it is even a good way to install Mayan-EDMS. I can only tell you that it appears to be working here. I would appreciate any feedback that the more learned members of this forum might be able to offer. Here we go: 1)
Mayan-EDMS was initial installed using the virtual environment as described on the download page. I executed these commands from a directory that I created at “/opt/mayan” so that the virtual environment starts at “/opt/mayan/venv”.
2) I created several new directories: /var/www/django /var/www/django/cache /var/www/django/mayan-edms
3) I created a file “/var/www/django/mayan-edms/mayan-edms.wsgi” with the following contents: import os import sys import site # set up python path to virtual environment site.addsitedir(‘/opt/mayan/venv/lib/python2.7/site-packages’) sys.path.append(‘/var/www/django/mayan-edms’) os.environ[‘PYTHON_EGG_CACHE’]=’/var/www/django/cache’ #django WSGI specifics From django.core.handlers.wsgi import WSGIHandler os.environ[‘DJANGO_SETTING_MODULE’] = ‘mayan.settings.srmc’ # Note: srmc.py is the file with our local #Salem Regional Medical Center settings application = WSGIHandler() 4) In “/etc/apache2/sites-available”, I created a file called “001-mayan.conf” with the following: ServerName mayanedms.salemhosp.com
ServerName mayanedms.salemhosp.com ServerAdmin [email protected] DocumentRoot /var/www/django/mayan-edms Alias /media /var/www/django/mayan-edms/media Order allow,deny Allow from all WSGIScriptAlias / /var/www/django/mayan-edms/mayan-edms.wsgi Order allow,deny Allow from all
5) I made a symbolic link from the file above in the directory “/etc/apache2/sites-enabled” 6) I changed the group of all files and directories beneath “/var/www/django” to www-data. 7) I restarted the “apache2” service on the server
Once I completed these steps, I was able to reach the login screen of Mayan-EDMS via http://mayanedms.salemhosp.com. Unfortunately, everything looked awful because the images, fonts, and icons used by Mayan-EDMS were not being served. According to the documentation, one should run “./manage.py collectstatic” to fix the problem. This did not work for me. Upon doing a little digging, I found that if I changed my directory to “/opt/mayan” and ran “mayan-edms.py collectstatic” the system offered to collect the static files for me and issued a warning that any such pre-existing files would be deleted. Since there were no pre-existing files, I typed “y” and the collection of static files proceeded normally. Upon restarting “apache2”, everything looked great EXCEPT for the login screen, which still lacks images an icons. I decided I could live with this.
I hope this information is useful to others. I tried to remember exactly all the steps that I followed to get here, but I may have made errors or omissions in this document. I you follow this procedure and get different results, please feel free to email me so that we can compare notes and see what might have caused the problems. I will update this document with any changes that might be necessary.