Table of Contents

  1. Introduction

  2. Why Choose a VPS for Dolibarr

  3. Choosing the Right VPS Provider and Specifications

  4. Preparing Your VPS Environment

  5. Installing the LAMP/LEMP Stack

  6. Creating a Database for Dolibarr

  7. Downloading and Deploying Dolibarr

  8. Configuring Apache or NGINX for Dolibarr

  9. Securing Your Server and Dolibarr Installation

  10. Setting File and Folder Permissions

  11. Running the Dolibarr Web Installer

  12. Post-Installation Optimization

  13. Setting Up Backups and Maintenance Routines

  14. Adding HTTPS and Securing with SSL

  15. Scaling and Monitoring

  16. Conclusion

  17. Resources and Tools


1. Introduction

Dolibarr ERP & CRM is a popular open-source solution for managing business processes including invoicing, inventory, CRM, HR, and more. While it can be installed on shared hosting, deploying Dolibarr on a VPS (Virtual Private Server) is the preferred method for businesses that demand better performance, full control, and security.

This article provides a detailed, step-by-step guide on how to deploy Dolibarr on a VPS from scratch. Whether you're a developer, system administrator, or a business owner with some technical background, this guide will walk you through everything from setting up your server to running a secure, production-ready Dolibarr instance.


2. Why Choose a VPS for Dolibarr

Choosing a VPS over shared hosting offers many benefits:

  • Full Control: Root access means you can configure services exactly as needed.

  • Better Performance: Dedicated resources (CPU, RAM) ensure stable operations.

  • Security: You control firewall rules, updates, and access levels.

  • Scalability: Upgrade your VPS as your Dolibarr usage grows.

  • Custom Configurations: Use specific PHP modules, database settings, or custom cron jobs.

A VPS is ideal for production environments where Dolibarr needs to perform reliably under real business conditions.


3. Choosing the Right VPS Provider and Specifications

Before starting, choose a reliable VPS provider. Recommended providers include:

  • DigitalOcean

  • Hetzner

  • Linode

  • OVH

  • Vultr

  • AWS Lightsail

3.1 Recommended Specifications for Dolibarr

Business Size RAM CPU Cores Disk (SSD) OS
Freelancers/SMBs 2 GB 1-2 cores 20–40 GB Ubuntu 22.04 LTS
Medium Businesses 4 GB 2–4 cores 50–80 GB Ubuntu 22.04 LTS
Growing Enterprises 8+ GB 4+ cores 100+ GB Ubuntu 22.04 LTS

Choose an OS version with long-term support (LTS) for security and stability.


4. Preparing Your VPS Environment

After spinning up your VPS, connect to it via SSH:

bash

ssh root@your-server-ip

Update your packages:

bash

apt update && apt upgrade -y

Install essential packages:

bash

apt install curl zip unzip git ufw software-properties-common -y

Create a new non-root user:

bash

adduser dolibarradmin usermod -aG sudo dolibarradmin

Then, re-login using this user for safer administration.


5. Installing the LAMP or LEMP Stack

Dolibarr runs on PHP, MySQL/MariaDB, and either Apache (LAMP) or NGINX (LEMP).

5.1 Using Apache (LAMP Stack)

Install Apache:

bash

apt install apache2 -y

Install PHP (recommended version: 8.1+):

bash

add-apt-repository ppa:ondrej/php apt update apt install php php-cli php-mysql php-curl php-xml php-mbstring php-zip php-gd php-intl php-soap libapache2-mod-php -y

Install MySQL/MariaDB:

bash

apt install mysql-server -y

Secure your installation:

bash

mysql_secure_installation

Enable Apache modules and restart:

bash

a2enmod rewrite systemctl restart apache2

5.2 Using NGINX (LEMP Stack)

For users who prefer NGINX:

bash

apt install nginx -y apt install php-fpm php-mysql php-curl php-xml php-mbstring php-zip php-gd php-intl php-soap -y

Then configure NGINX with PHP-FPM for Dolibarr (covered later).


6. Creating a Database for Dolibarr

Log into MySQL:

bash

mysql -u root -p

Create a database and user:

sql

CREATE DATABASE dolibarr CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'dolibarruser'@'localhost' IDENTIFIED BY 'strongpassword'; GRANT ALL PRIVILEGES ON dolibarr.* TO 'dolibarruser'@'localhost'; FLUSH PRIVILEGES; EXIT;

7. Downloading and Deploying Dolibarr

Navigate to your web root (for Apache):

bash

cd /var/www/html

Download the latest Dolibarr release:

bash

wget https://github.com/Dolibarr/dolibarr/archive/refs/tags/x.y.z.zip unzip x.y.z.zip mv dolibarr-x.y.z dolibarr

Ensure proper permissions:

bash

chown -R www-data:www-data /var/www/html/dolibarr chmod -R 755 /var/www/html/dolibarr

Replace x.y.z with the latest stable version.


8. Configuring Apache or NGINX for Dolibarr

8.1 Apache Virtual Host

Create a new virtual host file:

bash

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

Paste:

apache

<VirtualHost *:80> ServerName yourdomain.com DocumentRoot /var/www/html/dolibarr/htdocs <Directory /var/www/html/dolibarr/htdocs> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/dolibarr_error.log CustomLog ${APACHE_LOG_DIR}/dolibarr_access.log combined </VirtualHost>

Enable the site:

bash

a2ensite dolibarr.conf a2enmod rewrite systemctl reload apache2

8.2 NGINX Configuration

For NGINX, create:

bash

nano /etc/nginx/sites-available/dolibarr

Example config:

nginx

server { listen 80; server_name yourdomain.com; root /var/www/html/dolibarr/htdocs; index index.php index.html; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.1-fpm.sock; } location ~ /\.ht { deny all; } }

Enable and reload:

bash

ln -s /etc/nginx/sites-available/dolibarr /etc/nginx/sites-enabled/ systemctl reload nginx

9. Securing Your Server and Dolibarr Installation

9.1 Set UFW Firewall

Allow only essential ports:

bash

ufw allow OpenSSH ufw allow 'Apache Full' ufw enable

9.2 Change PHP Settings

Edit /etc/php/8.1/apache2/php.ini and tweak:

  • upload_max_filesize = 32M

  • post_max_size = 64M

  • max_execution_time = 120

Restart Apache:

bash

systemctl restart apache2

10. Setting File and Folder Permissions

Set proper ownership and permissions:

bash

chown -R www-data:www-data /var/www/html/dolibarr chmod -R 755 /var/www/html/dolibarr

Lock down the /documents folder after installation:

bash

chmod 700 /var/www/html/dolibarr/documents

11. Running the Dolibarr Web Installer

After setting up the server and configuring Apache or NGINX, it’s time to launch the Dolibarr web-based installer.

11.1 Access the Installer

Open your browser and go to:

arduino

http://yourdomain.com/install/

11.2 Step-by-Step Installation

  1. Language Selection: Choose your preferred language.

  2. Pre-requisite Check: The installer will check your PHP version, modules, permissions, and configuration. Make sure all checkboxes are green.

  3. Database Configuration:

    • Type: MySQL or MariaDB

    • Host: localhost

    • Database Name: dolibarr

    • User: dolibarruser

    • Password: your_password

  4. Database Initialization: Dolibarr will create tables and insert base data.

  5. Admin Account: Set up the first admin user (email, username, password).

  6. Finalization: Once complete, delete the /install/ directory:

bash

rm -rf /var/www/html/dolibarr/htdocs/install/

12. Post-Installation Optimization

After installing Dolibarr, there are several recommended optimizations:

12.1 Remove or Disable Unused Modules

Only enable the modules you need to reduce memory usage and complexity.

12.2 Set a Real Company Name and Logo

Navigate to:

Home > Setup > Company/Organization

Upload your logo and configure default currency, country, and fiscal year.

12.3 Configure Time Zone and Locale

In php.ini:

ini

date.timezone = "Europe/Paris"

Then:

bash

systemctl restart apache2

Dolibarr also allows per-user time zone configuration from their profile settings.


13. Setting Up Backups and Maintenance Routines

Dolibarr stores important business data, so automated backups are essential.

13.1 Database Backup

Create a daily backup script (e.g., /usr/local/bin/backup_dolibarr.sh):

bash

#!/bin/bash DATE=$(date +%F) mysqldump -u dolibarruser -p'your_password' dolibarr | gzip > /var/backups/dolibarr_db_$DATE.sql.gz

Make it executable:

bash

chmod +x /usr/local/bin/backup_dolibarr.sh

Add to crontab:

bash

crontab -e
ruby

0 2 * * * /usr/local/bin/backup_dolibarr.sh

13.2 Documents Folder Backup

Also back up /documents/, which stores invoices, PDFs, attachments:

bash

tar -czf /var/backups/dolibarr_documents_$(date +%F).tar.gz /var/www/html/dolibarr/documents/

14. Adding HTTPS and Securing with SSL

14.1 Install Certbot (Let’s Encrypt)

bash

apt install certbot python3-certbot-apache -y

14.2 Issue a Certificate

bash

certbot --apache -d yourdomain.com

Follow the prompts to enable HTTPS. Certbot will handle:

  • Certificate generation

  • HTTPS configuration

  • Automatic renewal

14.3 Test Renewal

bash

certbot renew --dry-run

15. Scaling and Monitoring

As your Dolibarr usage grows, consider enhancing your deployment with better infrastructure and monitoring tools.

15.1 Performance Scaling

  • Use a dedicated database server (e.g., AWS RDS, DigitalOcean Managed DB)

  • Enable Redis or Memcached for session caching

  • Use NGINX as a reverse proxy for better performance and SSL offloading

  • Add CDN (Cloudflare) for document delivery and DNS management

15.2 Monitoring Tools

  • UptimeRobot – Simple uptime checks

  • Netdata – Full-stack monitoring for CPU, RAM, DB, and disk

  • Zabbix – Enterprise-grade metrics

  • Fail2ban – Prevent brute force login attacks

  • Logrotate – Manage log file sizes and rotation


16. Conclusion

Deploying Dolibarr on a VPS gives you full control, strong performance, and long-term flexibility that shared hosting can’t offer. Whether you're managing one company or multiple legal entities with the MultiCompany module, a VPS provides the perfect foundation for a secure, scalable ERP system.

Here’s what you achieved in this deployment:

  • Set up a secure, optimized VPS environment

  • Installed and configured the Dolibarr application stack

  • Performed the web-based installation

  • Hardened the server with firewalls and HTTPS

  • Enabled automated backups and system monitoring

  • Positioned your system for future scaling and integrations

With this foundation, you can go further—by developing custom modules, connecting to APIs, or adding mobile access through external apps.


17. Resources and Tools