Webserver: Difference between revisions

m (add apache & nginx)
Tag: 2017 source edit
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
A Webserver is necessary for running Dolibarr.
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.


Usually the Apache 2 Webserver is used but you can also use nginx.


<br />
=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 :
 
<syntaxhighlight lang="console" line="1" start="1">
<VirtualHost *:80>
    LogLevel info
    ServerName dolibarr.local
    ServerAdmin admname@mail.com
    DocumentRoot /var/www/dolibarr
    ErrorLog ${APACHE_LOG_DIR}/error.dolibarr.log
    CustomLog ${APACHE_LOG_DIR}/access.dolibarr.log combined
</VirtualHost>
</syntaxhighlight>
 
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 :
 
<blockquote>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 <nowiki>https://$host$request_uri</nowiki>;
 
   }
 
       listen [::]:80;
 
       listen 80;
 
       server_name dolibarr.example.fr;
 
       return 404;
 
}</blockquote>

Latest revision as of 08:25, 21 December 2022

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 :

<VirtualHost *:80>
    LogLevel info
    ServerName dolibarr.local
    ServerAdmin admname@mail.com
    DocumentRoot /var/www/dolibarr
    ErrorLog ${APACHE_LOG_DIR}/error.dolibarr.log
    CustomLog ${APACHE_LOG_DIR}/access.dolibarr.log combined
</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;

}