Skip to content

Instantly share code, notes, and snippets.

@ff55lab
Last active April 19, 2023 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ff55lab/f39b4148c08b17fc75ea6761580efccb to your computer and use it in GitHub Desktop.
Save ff55lab/f39b4148c08b17fc75ea6761580efccb to your computer and use it in GitHub Desktop.
Setup Dolibarr on Ubuntu Server 20.04

Setup Dolibarr on Ubuntu Server

Simple guideline to setup Dolibarr on Ubuntu server. The time of writting this guideline was based on version 16.0.0.

DigitalOcean Referral Badge

Setup Ubuntu Server

Refer to this guideline to setup Ubuntu Server https://gist.github.com/ff55lab/6d43391b2d0f3e6950845d17ffa8cb1f

Environment

The environment was based on the below configurations

  • Dolibarr 16.0.0
  • Ubuntu Server 20.04
  • Apache 2

Step by step

References

Disclaimer

All information on this gist is used at your own risk and is not endorsed by any party.

Access Dolibarr Web Interface

  1. To access Dolibarr, go to your browser and visit http://Server_IP/. For example:
http://192.0.8.88/
  1. On the setup page, select the required language and click Next Step

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

  3. Enter Database information. Replace StrongPassword with your secure password

Database name: dolibarr
Driver type: MySQL / MariaDB
Database server: localhost
Login: dolibarr
Password: StrongPassword
  1. Click Next Step to save configurations

  2. 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

Go to top.

Using Certbot to Generate SSL Certificate

Heading to the certbot instruction page at https://certbot.eff.org/instructions

In this example, we refer to apache and DigitalOcean. So, choose the appropriate topic accordingly.

Choose the wildcard topic to implement and support multiple domain names.

Follow the instructions and your server will be implemented with SSL.

Remember to backup the below files in secure and safe place.

  • digitalocean.ini
  • fullchain.pem
  • privkey.pem

The certbot will be automatically scheduled to renew the SSL certificate before it is expired.

Alternatively, run the below command to create certificate:

user@ubuntu:~$ sudo certbot --apache

However, you may always test the automatic renewal by the certbot. Type the below command:

user@ubuntu:~$ sudo certbot renew --dry-run

If you accidentally create the wrong certificate, then run the below command:

user@ubuntu:~$ sudo certbot delete

Go to top.

Increase Default Lifetime of Session

Edit the PHP configuration file.

user@ubuntu:~$ sudo nano /etc/php/8.1/apache2/php.ini

At the [Session] area, amend the desired timeout in seconds

[Session]

; https://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 3600 ;1440

Go to top.

Install Apache

  1. Install the Apache server
user@ubuntu:~$ sudo apt -y install apache2
  1. Install libapache2-mod-php extension
user@ubuntu:~$ sudo apt install -y libapache2-mod-php
  1. Create a Virtual host file for each *.conf
user@ubuntu:~$ sudo nano /etc/apache2/sites-available/dolibarr.conf
user@ubuntu:~$ sudo nano /etc/apache2/sites-available/dolibarr22.conf

Add the following lines and save the file. Replace Server_IP with your Server IP

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName `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>

Another set of *.conf file

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName `Server_IP22`
     DocumentRoot /srv/dolibarr22/htdocs/

     <Directory /srv/dolibarr22/htdocs>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog /var/log/apache2/dolibarr22_error.log
     CustomLog /var/log/apache2/dolibarr22_access.log combined
</VirtualHost>
  1. Verify file syntax
user@ubuntu:~$ sudo apachectl -t
  1. Enable Dolibarr configuration file, disable default configuration file, and enable Apache rewrite mode
user@ubuntu:~$ sudo a2ensite dolibarr
user@ubuntu:~$ sudo a2dissite 000-default.conf
user@ubuntu:~$ sudo a2enmod rewrite
  1. Set proper directory permissions
user@ubuntu:~$ sudo chown -R www-data:www-data /srv/dolibarr
  1. Restart the Apache server
user@ubuntu:~$ sudo systemctl restart apache2

Go to top.

Install MariaDB

  1. Install MariaDB server and client
user@ubuntu:~$ sudo apt install mariadb-server mariadb-client
  1. Secure the database server
user@ubuntu:~$ sudo mysql_secure_installation
  1. Log in to the MariaDB shell as the root user
user@ubuntu:~$ sudo mysql -u root -p
  1. 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;
  1. Verify database creation
user@ubuntu:~$ mysql -u dolibarr -p
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| dolibarr           |
+--------------------+
2 rows in set (0.00 sec)

Go to top.

Install PHP

user@ubuntu:~$ 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

Go to top.

Lock Dolibarr Installation

After successfully setup Dolibarr Web Interface, it will suggest to lock the installation process.

sudo touch /srv/dolibarr/documents/install.lock

Go to top.

Secure Dolibarr Configuration File

When first login into Dolibarr, you will get the below warning.

Warning, your config file (htdocs/conf/conf.php) can be overwritten by the web server. This is a serious security hole. Modify permissions on file to be in read only mode for operating system user used by Web server. If you use Windows and FAT format for your disk, you must know that this file system does not allow to add permissions on file, so can't be completely safe. All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other Setup).

Run the below command to set configuration file as ready only to prevent access from web server.

user@ubuntu:~$ sudo chmod 0444 /srv/dolibarr/htdocs/conf/conf.php

Go to top.

Setup Dolibarr

  1. Download Dolibarr tarball
user@ubuntu:~$ wget https://github.com/Dolibarr/dolibarr/archive/16.0.0.tar.gz

Refer to Dolibarr releases https://wiki.dolibarr.org/index.php/Releases

  1. Extract the archive
user@ubuntu:~$ tar xvf 16.0.0.tar.gz
  1. Move extracted directory to /srv/dolibarr and delete the tarball
user@ubuntu:~$ sudo mv dolibarr-16.0.0 /srv/dolibarr
user@ubuntu:~$ sudo rm 16.0.0.tar.gz

Go to top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment