Webserver

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

A Webserver is necessary for running Dolibarr.

Usually the Apache 2 Webserver is used but you can also use Nginx, or any Web server with PHP support available.


Example of setup of a virtual host file for Apache

With a root access, create the configuration file /etc/apache2/sites-available/dolibarr.conf

Insert the following lines :

1 <VirtualHost *:80>
2     LogLevel info
3     ServerName dolibarr.local
4     ServerAdmin admname@mail.com
5     DocumentRoot /var/www/dolibarr
6     ErrorLog ${APACHE_LOG_DIR}/error.dolibarr.log
7     CustomLog ${APACHE_LOG_DIR}/access.dolibarr.log combined
8 </VirtualHost>

ServerName is the URL base. You will use it in your web browser to access to Dolibarr. ServerAdmin should not use a real mail address.

Activate the configuration :

a2ensite dolibarr.conf

Restart the apache server :

systemctl reload apache2

Example of setup of a virtual host file for Nginx

Here is a configuration file for Nginx working in HTTPS on Debian 11, PHP7.4, Nginx 1.18 et Dolibarr 14 :

server {

       root /var/www/dolibarr/htdocs;

       index index.html index.php;

       server_name dolibarr.example.fr;

       location / {

               try_files $uri $uri/ =404;

       }

       location ~ [^/]\.php(/|$) {

               fastcgi_intercept_errors on;

               include         fastcgi_params;

               fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

               fastcgi_param   SCRIPT_NAME $fastcgi_script_name;

               fastcgi_pass unix:/run/php/php7.4-fpm.sock;

       }

   listen [::]:443 ssl ipv6only=on;

   listen 443 ssl;

   ssl_certificate /etc/letsencrypt/live/dolibarr.example.fr/fullchain.pem;

   ssl_certificate_key /etc/letsencrypt/live/dolibarr.example.fr/privkey.pem;

   include /etc/letsencrypt/options-ssl-nginx.conf;

   ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

   error_log /var/log/nginx/dolibarr.example.fr/error.log warn;

   access_log /var/log/nginx/dolibarr.example.fr/access.log;

}

server {

   if ($host = dolibarr.example.fr) {

       return 301 https://$host$request_uri;

   }

       listen [::]:80;

       listen 80;

       server_name dolibarr.example.fr;

       return 404;

}