How to Install Dolibarr on Ubuntu 20.04

Updated on November 21, 2023
How to Install Dolibarr on Ubuntu 20.04 header image

Introduction

Dolibarr is an open-source Enterprise Resource Planning (ERP) and Customer Relationship Management (CRM) software used to manage sales, purchases, inventories, and other daily activities of organizations of any size. Some primary features of Dolibarr are:

  • Sales Management
  • Commercial proposals management
  • Stock Management
  • Project Management
  • Manufacturing resource planning

This tutorial explains how to install Dolibarr on Ubuntu 20.04.

Prerequisites

Before you begin the tutorial, you should:

Install PHP

Install PHP and required extensions.

    $ sudo apt install -y php php-cli php-mysql php-common php-zip php-mbstring php-xmlrpc php-curl php-soap php-gd php-xml php-intl php-ldap

Install MariaDB

  1. Install MariaDB server and client.

     $ sudo apt install mariadb-server mariadb-client
  2. Secure the database server.

     $ sudo mysql_secure_installation

    Answer all the security questions.

  3. Log in to the MariaDB shell as the root user.

     $ sudo mysql -u root -p
  4. Create a database and user for Dolibarr. Replace 'StrongPassword' with your secure password.

     CREATE USER 'dolibarr'@'localhost' IDENTIFIED BY 'StrongPassword';
     CREATE DATABASE dolibarr;
     GRANT ALL PRIVILEGES ON dolibarr.* TO 'dolibarr'@'localhost';
     FLUSH PRIVILEGES;
     EXIT;
  5. Verify database creation.

     $ mysql -u dolibarr -p
     MariaDB [(none)]> SHOW DATABASES;
     +--------------------+
     | Database           |
     +--------------------+
     | information_schema |
     | dolibarr           |
     +--------------------+
     2 rows in set (0.00 sec)

Setup Dolibarr

  1. Download Dolibarr tarball.

     $ wget https://github.com/Dolibarr/dolibarr/archive/12.0.5.tar.gz
  2. Extract the archive.

     $ tar xvf 12.0.5.tar.gz
  3. Move extracted directory to /srv/dolibarr and delete the tarball.

     $ sudo mv dolibarr-12.0.5 /srv/dolibarr
     $ sudo rm 12.0.5.tar.gz

Install Apache

  1. Install the Apache server.

     $ sudo apt -y install apache2
  2. Install libapache2-mod-php extension.

     $ sudo apt install -y libapache2-mod-php
  3. Create a Virtual host file.

     $ sudo nano /etc/apache2/sites-available/dolibarr.conf

    Add the following lines and save the file. Replace <http://Server_IP/> with your Server IP.

     <VirtualHost *:80>
          ServerAdmin webmaster@example.com
          ServerName <http://Server_IP/>             
          DocumentRoot /srv/dolibarr/htdocs/
    
          <Directory /srv/dolibarr/htdocs>
             Options +FollowSymlinks
             AllowOverride All
             Require all granted
          </Directory>
    
          ErrorLog /var/log/apache2/dolibarr_error.log
          CustomLog /var/log/apache2/dolibarr_access.log combined
     </VirtualHost>
  4. Verify file syntax.

     $ sudo apachectl -t
  5. Enable Dolibarr configuration file, disable default configuration file, and enable Apache rewrite mode.

     $ sudo a2ensite dolibarr
     $ sudo a2dissite 000-default.conf
     $ sudo a2enmod rewrite
  6. Set proper directory permissions.

     $ sudo chown -R www-data:www-data /srv/dolibarr
  7. Restart the Apache server.

     $ sudo systemctl restart apache2

Access Dolibarr Web Interface

  1. To access Dolibarr, go to your browser and visit http://Server_IP/. For example:

     http://192.0.2.10/
  2. On the setup page, select the required language and click Next Step.

  3. Verify all installation prerequisite checks the click Start to begin the installation.

  4. Enter Database information. Replace 'StrongPassword' with your secure password.

     Database name: dolibarr
     Driver type: MySQL / MariaDB
     Database server: localhost
     Login: dolibarr
     Password: StrongPassword

    Click Next step to save configurations.

  5. On the last page, create administration credentials for Dolibarr Web UI and click Next Step to finish the installation. Dolibarr redirects to the Login page post successful installation.

SSL Configuration

Install an SSL certificate if you plan to use Dolibarr in Production environments, as SSL ensures encrypted communication.

Prerequisites for SSL

  • A fully registered domain name. This article uses yourdomain.tld as an example.
  • DNS A records for yourdomain.tld and www.yourdomain.tld, which points to your server's IP address. Follow the instructions at your domain registrar or use Vultr DNS.
  • SSL certificate for the domain. You can buy from SSL vendors or install a free Let's Encrypt certificate.

Edit Apache Config

  1. Edit the virtual host file.

     sudo nano /etc/apache2/sites-available/dolibarr.conf

    Edit the server name parameter and save the file.

     <VirtualHost *:80>
          ServerAdmin webmaster@example.com
          ServerName yourdomain.tld             
          DocumentRoot /srv/dolibarr/htdocs/
    
          <Directory /srv/dolibarr/htdocs>
             Options +FollowSymlinks
             AllowOverride All
             Require all granted
          </Directory>
    
          ErrorLog /var/log/apache2/dolibarr_error.log
          CustomLog /var/log/apache2/dolibarr_access.log combined
     </VirtualHost>
  2. Restart the Apache server to apply changes.

     $ sudo systemctl restart apache2
  3. Dolibarr should now be communicating through HTTPS.

Conclusion

This completes the steps to install Dolibarr on Ubuntu 20.04. For more information, refer to the official Dolibarr documentation.