Direct deployment

Mayan EDMS should be deployed like any other Django project and preferably using virtualenv. Below are some ways to deploy and use Mayan EDMS.

Being a Django and a Python project, familiarity with these technologies is recommended to better understand why Mayan EDMS does some of the things it does.

Compilers and development libraries will be installed to compile runtime libraries. LibreOffice and Poppler utils will also be installed as they are used to convert document files. Supervisor (, a Process Control System, will be used to monitor and keep all Mayan processes running.

Basic deployment

This setup uses less memory and CPU resources at the expense of some speed. For another setup that offers more performance and scalability refer to the Advanced deployment below.

  1. Install binary dependencies:

    If using a Debian or Ubuntu based Linux distribution, get the executable requirements using:

    sudo apt-get install --yes exiftool g++ gcc coreutils ghostscript \
    gnupg1 graphviz libfuse2 libjpeg-dev libmagic1 libpq-dev libpng-dev \
    libreoffice libtiff-dev poppler-utils postgresql python3-dev \
    python3-venv redis-server sane-utils supervisor tesseract-ocr \


    For Mayan EDMS 4.1, Supervisord must be upgraded to version 4.2.2. See troubleshooting section: After upgrade to version 4.1


    Platforms with the ARM CPU might also need additional requirements:

    sudo apt-get install --yes libffi-dev libssl-dev
  2. Create the user account for the installation:

    This will create an unprivileged user account that is also unable to login:

    sudo adduser mayan --disabled-password --disabled-login --gecos ""
  3. Create the parent directory where the project will be deployed:

    /opt/ is a good choice as it is meant is for “software and add-on packages that are not part of the default installation”. ( Create the /opt directory if it doesn’t already exists:

    sudo mkdir --parent /opt
  4. Create the Python virtual environment:

    This will keep all the Python packages installed here isolated from the rest of the Python packages in the system:

    sudo python3 -m venv /opt/mayan-edms/
  5. Make the mayan user the owner of the installation directory:

    sudo chown mayan:mayan /opt/mayan-edms/ -R
  6. Upgrade to the latest pip version:

    sudo -u mayan /opt/mayan-edms/bin/pip install -U pip
  7. Install Mayan EDMS from PyPI:

    sudo -u mayan /opt/mayan-edms/bin/pip install mayan-edms
  8. Install the Python client for PostgreSQL and Redis:

    sudo -u mayan /opt/mayan-edms/bin/pip install psycopg2==2.8.6 redis==3.5.3


    Platforms with the ARM CPU might also need additional requirements:

    sudo -u mayan /opt/mayan-edms/bin/pip install psutil==5.8.0
  9. Create the database for the installation:

    sudo -u postgres psql -c "CREATE USER mayan WITH password 'mayanuserpass';"
    sudo -u postgres createdb -O mayan mayan
  10. Configure Redis:

    Configure Redis to discard data when it runs out of memory, not save its database, keep 3 database, and be password protected:

    echo "maxmemory-policy allkeys-lru" | sudo tee -a /etc/redis/redis.conf
    echo "save \"\"" | sudo tee -a /etc/redis/redis.conf
    echo "databases 3" | sudo tee -a /etc/redis/redis.conf
    echo "requirepass mayanredispassword" | sudo tee -a /etc/redis/redis.conf
    sudo systemctl restart redis
  11. Initialize the project:

    This step will create all the database structures, download and compress static media files like JavaScript libraries and HTML frameworks, and create and initial admin account with a random password.


    For simplicity, the MAYAN_MEDIA_ROOT folder is set to be a subfolder of the installation. If you want to keep your files separated from the installation files, change the value of the MAYAN_MEDIA_ROOT variable in this and all subsequent steps. Be sure to first create the folder and give ownership of it to the mayan user with the chown command.


    If this step is interrupted, even if it is later resumed, will cause the automatic admin user to not be created in some cases. Make sure all environment variables and values are correct. If this happens, refer to the troubleshooting chapters: Missing automatic admin account after installation and Admin password reset.

    sudo -u mayan \
    MAYAN_CELERY_BROKER_URL="redis://:mayanredispassword@" \
    MAYAN_CELERY_RESULT_BACKEND="redis://:mayanredispassword@" \
    MAYAN_DATABASES="{'default':{'ENGINE':'django.db.backends.postgresql','NAME':'mayan','PASSWORD':'mayanuserpass','USER':'mayan','HOST':''}}" \
    MAYAN_LOCK_MANAGER_BACKEND="mayan.apps.lock_manager.backends.redis_lock.RedisLock" \
    MAYAN_LOCK_MANAGER_BACKEND_ARGUMENTS="{'redis_url':'redis://:mayanredispassword@'}" \
    MAYAN_MEDIA_ROOT="/opt/mayan-edms/media/" \
    /opt/mayan-edms/bin/ initialsetup
  12. Create the supervisor file at /etc/supervisor/conf.d/mayan-edms.conf:


    The generated supervisor file assumes Mayan EDMS is being installed into /opt/mayan-edms/. If you are installing Mayan EDMS in a different location, you must manually review the produced /etc/supervisor/conf.d/mayan-edms.conf file and update all directory references from /opt/mayan-edms/ to match your custom installation directory.

    sudo -u mayan MAYAN_MEDIA_ROOT="/opt/mayan-edms/media/" /opt/mayan-edms/bin/ platformtemplate supervisord | sudo sh -c "cat > /etc/supervisor/conf.d/mayan-edms.conf"
  13. Enable and restart the services [1]:

    sudo systemctl enable supervisor
    sudo systemctl restart supervisor
  14. Cleaning up:

    The following operating system dependencies are only needed during installation and can be removed.

    sudo apt-get remove --purge --yes libjpeg-dev libpq-dev libpng-dev libtiff-dev zlib1g-dev

Advanced deployment

This variation uses RabbitMQ as the message broker. RabbitMQ consumes more memory but scales to thousands of messages per second. RabbitMQ messages are also persistent by default, this means that pending tasks are not lost in the case of a restart or power failure. The Gunicorn workers are increased as well as the concurrency of the task workers.

  1. Install RabbitMQ:

    If using a Debian or Ubuntu based Linux distribution, get the executable requirements using:

    sudo apt-get install --yes rabbitmq-server
  2. Install the Python client for RabbitMQ:

    sudo -u mayan /opt/mayan-edms/bin/pip install amqp==2.6.1
  3. Create the RabbitMQ user and vhost:

    sudo rabbitmqctl add_user mayan mayanrabbitmqpassword
    sudo rabbitmqctl add_vhost mayan
    sudo rabbitmqctl set_permissions -p mayan mayan ".*" ".*" ".*"
  4. Edit the config file at /opt/mayan-edms/media/config.yml:






    Only replace the CELERY_BROKER_URL setting to use RabbitMQ, the CELERY_RESULT_BACKEND setting should remain unchanged.

  5. Increase the number of Gunicorn workers. Use 2 to 4 times the number of CPU cores. Edit the supervisor file at /etc/supervisor/conf.d/mayan-edms.conf and change only the -w argument. Example for 3 workers:

    command = /opt/mayan-edms/bin/gunicorn ... -w 3 ...
  6. Remove (or increase) the concurrency limit of the workers. Edit the supervisor file at /etc/supervisor/conf.d/mayan-edms.conf and edit or remove the argument --concurrency=1. Change one worker at a time, restart, and profile with your workload.

  7. Restart the services:

    sudo supervisorctl reread
    sudo supervisorctl restart all