Raspberry Pi SOGo Groupware: Difference between revisions

From WickyWiki
m SOGo 5.1
Line 5: Line 5:
= Start =
= Start =


SOGo is a groupware server that allows you to share agenda and contacts with others within your own private network. There is also the popular NextCloud (https://nextcloud.com) which would have been my second option. However, SOGo proved to be relatively easy to setup, I like it and am using it for some time now.
SOGo is a groupware server that allows you to share agenda and contacts with others within your own private network. There are good alternatives, however, SOGo proved to be relatively easy to setup, I like it and am using it for some time now.


SOGo nightly builds are freely available for the public but there are no binaries or configurations available for the ARM architecture as are needed for the Raspberry Pi. Therefore we need to compile, build and install the application manually and then solve some problems.
SOGo nightly builds are freely available for the public but there are no binaries or configurations available for the ARM architecture as are needed for the Raspberry Pi. Therefore we need to compile, build and install the application manually and then solve some problems.


Source with some pointers:
= Changes SOGo 3.x, 4.x -> 5.x =
* https://lists.inverse.ca/sogo/arc/users/2016-07/msg00063.html


Assumptions:
Changes have been incoorperated in the instruction and are not explicitly included here.
* Apache2 (2.4+) is installed
* MariaDB (MySQL) is installed
* There is no information here concerning the creation of the sogo database tables


= Compile, build and install =
* We can no longer use '--prefix=/usr/System' as in:
./configure --with-gnustep --enable-debug --disable-strip --prefix=/usr/System
 
As a result many directory locations will have changed. For example the location of the service will be:
/usr/local/sbin/sogod
 
In stead of:
/usr/sbin/sogod
 
Libraries will be in:
/usr/local/lib/sogo/*
 
In stead of:
/usr/lib/sogo/*
 
* The database from version 3.x to 4.x has some changes. See troubleshooting.
 
= Preperation =
 
== Install MariaDB database ==
 
<source lang=bash>
sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
systemctl status mariadb
</source>
 
<source lang=bash>
sudo mysql_secure_installation
</source>
 
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
 
== Install Nginx webserver ==
 
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
systemctl status nginx
 
= SOGo download, compile, build and install =


== Download source-code ==
== Download source-code ==


Get and extract source-code of SOPE and SOGo (the version used here is 3.2.10):
Get and extract source-code of SOPE and SOGo (the version used here is 5.1.0):


<syntaxhighlight lang=bash>
<source lang=bash>
cd ~
cd ~
wget https://sogo.nu/files/downloads/SOGo/Sources/SOPE-3.2.10.tar.gz
wget https://sogo.nu/files/downloads/SOGo/Sources/SOPE-5.1.0.tar.gz
tar -xvzf SOPE-3.2.10.tar.gz
tar -xvzf SOPE-*.tar.gz
wget https://sogo.nu/files/downloads/SOGo/Sources/SOGo-3.2.10.tar.gz
wget https://sogo.nu/files/downloads/SOGo/Sources/SOGo-5.1.0.tar.gz
tar -xvzf SOGo-3.2.10.tar.gz
tar -xvzf SOGo-*.tar.gz
mv SOGo-3.2.10 SOGo
mv SOGo-* SOGo
</syntaxhighlight>
</source>


== Install needed packages for SOPE ==
== SOPE: Install needed packages ==


<syntaxhighlight lang=bash>
<source lang=bash>
# the GNU Objective-C compiler (gcc-objc)
# the GNU Objective-C compiler (gcc-objc)
sudo apt-get install gnustep-make #20Mb
sudo apt-get install gnustep-make
sudo apt-get install gnustep-core-devel #34Mb
sudo apt-get install gnustep-core-devel
# the libxml2 development headers (74Mb)
# the libxml2 development headers
sudo apt-get install libxml2-dev
sudo apt-get install libxml2-dev
sudo apt-get install libwbxml2-dev  
sudo apt-get install libwbxml2-dev  
# the OpenLDAP development headers (2mb)
# the OpenLDAP development headers
sudo apt-get install libldap2-dev
sudo apt-get install libldap2-dev
# the OpenSSL development headers (10Mb)
# the OpenSSL development headers
sudo apt-get install libssl-dev  
sudo apt-get install libssl-dev  
# the PostgreSQL development headers (1Mb)
# the PostgreSQL development headers
sudo apt-get install libpq-dev
sudo apt-get install libpq-dev
# the MySql (MariaDB) development headers (6Mb)
# the MySql (MariaDB) development headers  
# sudo apt-cache search mysql | grep "dev"
# sudo apt-cache search mysql | grep "dev"
sudo apt-get install libmariadbclient-dev-compat
sudo apt-get install libmariadbclient-dev-compat
</syntaxhighlight>
</source>


== Compile and install SOPE ==
== SOPE: Compile and install ==


Compiling (make) will take considerable time and may show some warnings which we can hopefully ignore.
Compiling (make) will take up to an hour, depending on the hardware and will show some warnings which we can hopefully ignore.


<syntaxhighlight lang=bash>
<source lang=bash>
cd ~/SOPE
cd ~/SOPE
./configure --with-gnustep --enable-debug --disable-strip --prefix=/usr/System
./configure --with-gnustep --enable-debug --disable-strip


sudo make uninstall
sudo make uninstall
Line 64: Line 106:
make
make
sudo make install
sudo make install
</syntaxhighlight>
</source>


== Install additional needed packages for SOGo ==
== SOGo: Install additional needed packages ==


<syntaxhighlight lang=bash>
<source lang=bash>
# the libmemcached development headers (2Mb)
# the libmemcached development headers
sudo apt-get install libmemcached-dev
sudo apt-get install libmemcached-dev
# the libcurl development headers (1Mb)
# the libcurl development headers
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libcurl4-openssl-dev
# libsodium (encryption) development headers  
# libsodium (encryption) development headers (added for SOGo 5.1)
sudo apt-get install libsodium-dev  
sudo apt-get install libsodium-dev  
# libzip development headers  
# libzip development headers (added for SOGo 5.1)
sudo apt-get install libzip-dev
sudo apt-get install libzip-dev
</syntaxhighlight>
</source>


== Compile and install SOGo ==
== SOGo: Compile and install ==


<syntaxhighlight lang=bash>
Compiling (make) will take up to 30 minutes, depending on the hardware and will show quite some warnings which we can hopefully ignore.
 
<source lang=bash>
cd ~/SOGo
cd ~/SOGo
./configure --enable-debug --disable-strip
./configure --enable-debug --disable-strip
Line 89: Line 133:
make
make
sudo make install
sudo make install
</syntaxhighlight>
</source>


= Post installation =
= Post installation =
Line 97: Line 141:
== Create user and group 'sogo' ==
== Create user and group 'sogo' ==


<syntaxhighlight lang=bash>
<source lang=bash>
#Create group
#Create group
sudo addgroup sogo
sudo addgroup sogo
Line 104: Line 148:
#Add existing user 'sogo' to group 'sogo'
#Add existing user 'sogo' to group 'sogo'
sudo adduser sogo sogo
sudo adduser sogo sogo
</syntaxhighlight>
</source>


== Copy some files to the right places ==
== Copy some files to the right places ==


<syntaxhighlight lang=bash>
<source lang=bash>
cd ~/SOGo
cd ~/SOGo
sudo install -D -m 644 Scripts/sogo-default /etc/default/sogo
sudo install -D -m 644 Scripts/sogo-default /etc/default/sogo
Line 117: Line 161:
sudo install -d -m 750 /etc/sogo/
sudo install -d -m 750 /etc/sogo/
sudo install -D -m 640 Scripts/sogo.conf /etc/sogo/sogo.conf  
sudo install -D -m 640 Scripts/sogo.conf /etc/sogo/sogo.conf  
</syntaxhighlight>
</source>


== Apply owner and group information ==
== Apply owner and group information ==


<syntaxhighlight lang=bash>
<source lang=bash>
sudo mkdir /var/log/sogo
sudo mkdir /var/log/sogo
sudo mkdir /var/run/sogo
sudo mkdir /var/run/sogo
sudo chown -R sogo:sogo /var/run/sogo
sudo chown -R sogo:sogo /var/run/sogo
sudo chown -R sogo:sogo /var/log/sogo
sudo chown -R sogo:sogo /var/log/sogo
sudo chown -R sogo:sogo /usr/lib/GNUstep/SOGo
sudo chown -R sogo:sogo /etc/sogo
sudo chown -R sogo:sogo /etc/sogo
</syntaxhighlight>
sudo chown -R sogo:sogo /usr/local/lib/GNUstep/SOGo
</source>


== Install Service ==
== Provide the new location of the shared libraries ==


For installation of the service we use the file './SOGo/Scripts/sogo-systemd-redhat':
Create this file with one line of text:


<syntaxhighlight lang=bash>
<source lang=bash>
sudo nano /etc/ld.so.conf.d/sogo.conf
<source>
 
/usr/local/lib/sogo
 
Reload the configuration:
 
<source lang=bash>
sudo ldconfig
</source>
 
== SOGo database and sogo.conf settings ==
 
Go here: [[SOGo]]
 
== Import sogo mariaDb database==
 
<source lang=bash>
sudo mysql -u root -p
sql> source /home/pi/sogo.sql
</source>
 
See: https://wjv.duckdns.org/mediawiki/index.php/MySQL#Restore_one_database
 
== Install and start the service ==
 
For installation of the service we use and modify the file './SOGo/Scripts/sogo-systemd-redhat':
 
<source lang=bash>
cd ~/SOGo
cd ~/SOGo
sudo install -D -m 644 Scripts/sogo-systemd-redhat /lib/systemd/system/sogo.service
sudo install -D -m 644 Scripts/sogo-systemd-redhat /lib/systemd/system/sogo.service
sudo systemctl daemon-reload
sudo systemctl daemon-reload
sudo systemctl enable sogo
sudo systemctl enable sogo
</syntaxhighlight>
</source>
 
<source lang=bash>
sudo service sogo restart
</source>
 
= Configure Nginx webserver =
 
See: http://wiki.sogo.nu/nginxSettings
 
<source lang=bash>
cd /etc/nginx/sites-available/
sudo nano sogo
</source>
 
<source lang=nginx>
server
{
  listen      80 default;
  server_name 192.168.1.14;
  # redirect http to https
  rewrite    ^ https://$server_name$request_uri? permanent;
}
server
{
  listen 443;
  server_name 192.168.1.14;
  root /usr/local/lib/GNUstep/SOGo/WebServerResources/;
  ssl on;
  ssl_certificate /etc/nginx/ssl/server.cer;
  ssl_certificate_key /etc/nginx/ssl/server.key;
  # requirement to create new calendars in Thunderbird
  proxy_http_version 1.1;
 
  # Message size limit
  client_max_body_size 50m;
  client_body_buffer_size 128k;
 
  location = /
  {
  rewrite ^ https://$server_name/SOGo;
  allow all;
  }
 
  # For iOS 7
  location = /principals/
  {
  rewrite ^ https://$server_name/SOGo/dav;
  allow all;
  }
  location ^~/SOGo
  {
  proxy_pass http://127.0.0.1:20000;
  proxy_redirect http://127.0.0.1:20000 default;
  # forward user's IP address
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $host;
  proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  proxy_set_header x-webobjects-remote-host 127.0.0.1;
  proxy_set_header x-webobjects-server-name $server_name;
  proxy_set_header x-webobjects-server-url $scheme://$host;
  proxy_set_header x-webobjects-server-port $server_port;
  proxy_connect_timeout 90;
  proxy_send_timeout 90;
  proxy_read_timeout 90;
  proxy_buffer_size 4k;
  proxy_buffers 4 32k;
  proxy_busy_buffers_size 64k;
  proxy_temp_file_write_size 64k;
  break;
  }
  location /SOGo.woa/WebServerResources/
  {
  alias /usr/local/lib/GNUstep/SOGo/WebServerResources/;
  allow all;
  expires max;
  }
 
  location /SOGo/WebServerResources/
  {
  alias /usr/local/lib/GNUstep/SOGo/WebServerResources/;
  allow all;
  expires max;
  }
 
  location (^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$)
  {
  alias /usr/local/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  expires max;
  }


== Other configuration ==
  location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$)
  {
  alias /usr/local/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  expires max;
  }
  }
</source>


See:
Enable site:
* For website configuration file: [[Apache2 configuration for SOGo and MediaWiki#Configuration_.28Raspberry_Pi.29|Apache2 configuration for SOGo and MediaWiki]]
* For database and sogo.conf settings: [[SOGo]]


And maybe also:
<source lang=bash>
* [[Create_certificates_for_Apache2]]
sudo ln -s /etc/nginx/sites-available/sogo /etc/nginx/sites-enabled/
* [[Apache2 webserver]]
</source>


= Start the Service =
Test and start:


<syntaxhighlight lang=bash>
<source lang=bash>
sudo service sogo restart
sudo nginx -t
</syntaxhighlight>
sudo systemctl restart nginx
</source>


= Troubleshooting =
= Troubleshooting =


== Missing /var/run/sogo/sogo.pid ==
== Failed to acquire channel for URL: mysql://sogo ==
 
You need a sogo database and a sogo database user.  
 
== ExecutionFailed REASON:Unknown column c_hascertificate ==
 
You need to upgrade the database frm 3.x to 4.x.
 
<source lang=bash>
sudo /home/pi/SOGo/Scripts/sql-update-3.2.10_to_4.0.0-mysql.sh
</source>


Error: sogo.service: PID file /var/run/sogo/sogo.pid not readable (yet?) after start: No such file or directory
Provide the sogo database user and password.
== /var/run/sogo/sogo.pid No such file or directory ==


In my case the directory /var/run/sogo is an in-memory folder (tmpfs), it is gone after reboot resulting in the above error.  This might be fixed in later editions, for now we will edit systemd sogo.service file to create the directory at startup of the sogo service.
In my case the directory /var/run/sogo is an in-memory folder (tmpfs), it is gone after reboot resulting in the above error.  This might be fixed in later editions, for now we will edit systemd sogo.service file to create the directory at startup of the sogo service.
Line 172: Line 352:
* https://www.freedesktop.org/software/systemd/man/systemd.service.html
* https://www.freedesktop.org/software/systemd/man/systemd.service.html


<syntaxhighlight lang=bash>
<source lang=bash>
sudo nano /lib/systemd/system/sogo.service
sudo nano /lib/systemd/system/sogo.service
</syntaxhighlight>
</source>


<blockquote>
<blockquote>
<syntaxhighlight lang=bash highlight="9,11-15">
<source lang=bash highlight="9,11-15">
[Unit]
[Unit]
Description=SOGo groupware server
Description=SOGo groupware server
Line 188: Line 368:
Environment="PREFORK=2"
Environment="PREFORK=2"
EnvironmentFile=-/etc/sysconfig/sogo
EnvironmentFile=-/etc/sysconfig/sogo
#Create /var/run/sogo, as root and ignore mkdir error
# Create /var/run/sogo, as root and ignore mkdir error
PermissionsStartOnly=true
PermissionsStartOnly=true
# exec with prefix - to ignore errors
# exec with prefix - to ignore errors
Line 194: Line 374:
ExecStartPre=/bin/chown -R sogo:sogo /var/run/sogo
ExecStartPre=/bin/chown -R sogo:sogo /var/run/sogo
# Start sogo
# Start sogo
ExecStart=/usr/sbin/sogod -WOWorkersCount ${PREFORK} -WOPidFile /var/run/sogo/sogo.pid -WOLogFile /var/log/so$
ExecStart=/usr/local/sbin/sogod -WOWorkersCount ${PREFORK} -WOPidFile /var/run/sogo/sogo.pid -WOLogFile /var/log/so$
PIDFile=/var/run/sogo/sogo.pid
PIDFile=/var/run/sogo/sogo.pid


[Install]
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
</syntaxhighlight>
</source>
</blockquote>
</blockquote>


Restart the service:
Restart the service:


<syntaxhighlight lang=bash>
<source lang=bash>
sudo systemctl daemon-reload
sudo systemctl daemon-reload
sudo systemctl restart sogo
sudo systemctl restart sogo
sudo systemctl status sogo
sudo systemctl status sogo
</syntaxhighlight>
</source>
 
== /etc/sogo/sogo.conf ==
 
This file needs to be readable by user 'sogo', but not by others. If you edit this file as root you need to reapply owner and group:
 
<source lang=bash>
sudo chown -R sogo:sogo /etc/sogo
</source>


== Logging ==
== Logging ==
Line 214: Line 402:
SOGo service status:
SOGo service status:


<syntaxhighlight lang=bash>
<source lang=bash>
service sogo status
service sogo status
</syntaxhighlight>
</source>
 
Apache service status:
 
<syntaxhighlight lang=bash>
service apache2 status
</syntaxhighlight>


Config files:
Config files:


<syntaxhighlight lang=bash>
<source lang=bash>
sudo ls -l /etc/sogo
sudo ls -l /etc/sogo
</syntaxhighlight>
</source>


SOGo log:
SOGo log:


<syntaxhighlight lang=bash>
<source lang=bash>
sudo tail -20 /var/log/sogo/sogo.log
sudo tail -20 /var/log/sogo/sogo.log
</syntaxhighlight>
</source>
 
Apache logs:
 
<syntaxhighlight lang=bash>
ls -l /var/log/apache2
</syntaxhighlight>
 
Apache log:
 
<syntaxhighlight lang=bash>
sudo tail -20 /var/log/apache2/access.log | grep SOGo
</syntaxhighlight>


<syntaxhighlight lang=bash>
sudo tail -20 /var/log/apache2/other_vhosts_access.log | grep SOGo
</syntaxhighlight>


== /etc/sogo/sogo.conf ==
= Apache2 modules (not updated) =
 
This file need to be readable by user 'sogo', but not by others. If you edit this file as root you need to reapply owner and group:
 
<syntaxhighlight lang=bash>
sudo chown -R sogo:sogo /etc/sogo
</syntaxhighlight>
 
== Apache2 ==


Make sure you have enabled all necessary modules.
Make sure you have enabled all necessary modules.


<syntaxhighlight lang=bash>
<source lang=bash>
sudo a2enmod headers
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy
Line 271: Line 430:
sudo a2enmod rewrite
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2enmod ssl
</syntaxhighlight>
</source>


If there is some sort of problem with the web service it could pay off to temporary increase the log level. For example, with the Apache configuration file 'raspberrypi.conf':
If there is some sort of problem with the web service it could pay off to temporary increase the log level. For example, with the Apache configuration file 'raspberrypi.conf':


<syntaxhighlight lang=bash>
<source lang=bash>
sudo nano /etc/apache2/sites-available/raspberrypi.conf
sudo nano /etc/apache2/sites-available/raspberrypi.conf
</syntaxhighlight>
</source>


<blockquote>
<blockquote>
<syntaxhighlight lang=bash>
<source lang=bash>
...
...
LogLevel debug
LogLevel debug
...
...
</syntaxhighlight>
</source>
</blockquote>
</blockquote>


<syntaxhighlight lang=bash>
<source lang=bash>
sudo service apache2 restart
sudo service apache2 restart
</syntaxhighlight>
</source>


More info:
More info:
* http://httpd.apache.org/docs/2.4/mod/core.html#loglevel
* http://httpd.apache.org/docs/2.4/mod/core.html#loglevel
* [[Create_certificates_for_Apache2]]
* [[Apache2 webserver]]
* [[Apache2 configuration for SOGo and MediaWiki#Configuration_.28Raspberry_Pi.29|Apache2 configuration for SOGo and MediaWiki]]
Note that locations have changed from /usr/ to usr/local/

Revision as of 16:55, 6 April 2021


Start

SOGo is a groupware server that allows you to share agenda and contacts with others within your own private network. There are good alternatives, however, SOGo proved to be relatively easy to setup, I like it and am using it for some time now.

SOGo nightly builds are freely available for the public but there are no binaries or configurations available for the ARM architecture as are needed for the Raspberry Pi. Therefore we need to compile, build and install the application manually and then solve some problems.

Changes SOGo 3.x, 4.x -> 5.x

Changes have been incoorperated in the instruction and are not explicitly included here.

  • We can no longer use '--prefix=/usr/System' as in:

./configure --with-gnustep --enable-debug --disable-strip --prefix=/usr/System

As a result many directory locations will have changed. For example the location of the service will be: /usr/local/sbin/sogod

In stead of: /usr/sbin/sogod

Libraries will be in: /usr/local/lib/sogo/*

In stead of: /usr/lib/sogo/*

  • The database from version 3.x to 4.x has some changes. See troubleshooting.

Preperation

Install MariaDB database

sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
systemctl status mariadb
sudo mysql_secure_installation

You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y

Install Nginx webserver

sudo apt install nginx -y sudo systemctl start nginx sudo systemctl enable nginx systemctl status nginx

SOGo download, compile, build and install

Download source-code

Get and extract source-code of SOPE and SOGo (the version used here is 5.1.0):

cd ~
wget https://sogo.nu/files/downloads/SOGo/Sources/SOPE-5.1.0.tar.gz
tar -xvzf SOPE-*.tar.gz
wget https://sogo.nu/files/downloads/SOGo/Sources/SOGo-5.1.0.tar.gz
tar -xvzf SOGo-*.tar.gz
mv SOGo-* SOGo

SOPE: Install needed packages

# the GNU Objective-C compiler (gcc-objc)
sudo apt-get install gnustep-make
sudo apt-get install gnustep-core-devel
# the libxml2 development headers
sudo apt-get install libxml2-dev
sudo apt-get install libwbxml2-dev 
# the OpenLDAP development headers
sudo apt-get install libldap2-dev
# the OpenSSL development headers
sudo apt-get install libssl-dev 
# the PostgreSQL development headers
sudo apt-get install libpq-dev
# the MySql (MariaDB) development headers 
# sudo apt-cache search mysql | grep "dev"
sudo apt-get install libmariadbclient-dev-compat

SOPE: Compile and install

Compiling (make) will take up to an hour, depending on the hardware and will show some warnings which we can hopefully ignore.

cd ~/SOPE
./configure --with-gnustep --enable-debug --disable-strip

sudo make uninstall
make clean
make
sudo make install

SOGo: Install additional needed packages

# the libmemcached development headers
sudo apt-get install libmemcached-dev 	
# the libcurl development headers
sudo apt-get install libcurl4-openssl-dev
# libsodium (encryption) development headers (added for SOGo 5.1)
sudo apt-get install libsodium-dev 
# libzip development headers (added for SOGo 5.1)
sudo apt-get install libzip-dev

SOGo: Compile and install

Compiling (make) will take up to 30 minutes, depending on the hardware and will show quite some warnings which we can hopefully ignore.

cd ~/SOGo
./configure --enable-debug --disable-strip

sudo make uninstall
make clean
make
sudo make install

Post installation

The install script silently fails to execute some tasks, probably because there are no specific instructions for the Raspbian OS and ARM architecture. The following statements are based on the install scripts and documentation:

Create user and group 'sogo'

#Create group
sudo addgroup sogo
#Add new user 'sogo' to group 'sogo' (error if user sogo exists)
sudo useradd -g sogo sogo
#Add existing user 'sogo' to group 'sogo'
sudo adduser sogo sogo

Copy some files to the right places

cd ~/SOGo
sudo install -D -m 644 Scripts/sogo-default /etc/default/sogo
sudo install -D -m 644 packaging/debian/sogo.overrides /usr/share/lintian/overrides/sogo	
sudo install -D -m 644 Apache/SOGo.conf /etc/apache2/conf-available/SOGo.conf
sudo install -D -m 644 Scripts/sogo.cron /etc/cron.d/sogo
sudo install -D -m 644 Scripts/logrotate /etc/logrotate.d/sogo
sudo install -d -m 750 /etc/sogo/
sudo install -D -m 640 Scripts/sogo.conf /etc/sogo/sogo.conf

Apply owner and group information

sudo mkdir /var/log/sogo
sudo mkdir /var/run/sogo
sudo chown -R sogo:sogo /var/run/sogo
sudo chown -R sogo:sogo /var/log/sogo
sudo chown -R sogo:sogo /etc/sogo
sudo chown -R sogo:sogo /usr/local/lib/GNUstep/SOGo

Provide the new location of the shared libraries

Create this file with one line of text:

sudo nano /etc/ld.so.conf.d/sogo.conf
<source>

	 /usr/local/lib/sogo

Reload the configuration:

<source lang=bash>
sudo ldconfig

SOGo database and sogo.conf settings

Go here: SOGo

Import sogo mariaDb database

sudo mysql -u root -p
sql> source /home/pi/sogo.sql

See: https://wjv.duckdns.org/mediawiki/index.php/MySQL#Restore_one_database

Install and start the service

For installation of the service we use and modify the file './SOGo/Scripts/sogo-systemd-redhat':

cd ~/SOGo
sudo install -D -m 644 Scripts/sogo-systemd-redhat /lib/systemd/system/sogo.service
sudo systemctl daemon-reload
sudo systemctl enable sogo
sudo service sogo restart

Configure Nginx webserver

See: http://wiki.sogo.nu/nginxSettings

cd /etc/nginx/sites-available/
sudo nano sogo
server
{
   listen      80 default;
   server_name 192.168.1.14;
   # redirect http to https
   rewrite     ^ https://$server_name$request_uri? permanent; 
}
server
{
   listen 443;
   server_name 192.168.1.14;
   root /usr/local/lib/GNUstep/SOGo/WebServerResources/; 
   ssl on;
   ssl_certificate /etc/nginx/ssl/server.cer;
   ssl_certificate_key /etc/nginx/ssl/server.key;
   # requirement to create new calendars in Thunderbird
   proxy_http_version 1.1;
   
   # Message size limit
   client_max_body_size 50m;
   client_body_buffer_size 128k;
   
   location = /
   {
	  rewrite ^ https://$server_name/SOGo; 
	  allow all; 
   }

   # For iOS 7
   location = /principals/
   {
	  rewrite ^ https://$server_name/SOGo/dav; 
	  allow all; 
   }
   location ^~/SOGo
   {
	  proxy_pass http://127.0.0.1:20000; 
	  proxy_redirect http://127.0.0.1:20000 default; 
	  # forward user's IP address 
	  proxy_set_header X-Real-IP $remote_addr; 
	  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
	  proxy_set_header Host $host; 
	  proxy_set_header x-webobjects-server-protocol HTTP/1.0; 
	  proxy_set_header x-webobjects-remote-host 127.0.0.1; 
	  proxy_set_header x-webobjects-server-name $server_name; 
	  proxy_set_header x-webobjects-server-url $scheme://$host; 
	  proxy_set_header x-webobjects-server-port $server_port; 
	  proxy_connect_timeout 90;
	  proxy_send_timeout 90;
	  proxy_read_timeout 90;
	  proxy_buffer_size 4k;
	  proxy_buffers 4 32k;
	  proxy_busy_buffers_size 64k;
	  proxy_temp_file_write_size 64k;
	  break;
   }
   location /SOGo.woa/WebServerResources/
   {
	  alias /usr/local/lib/GNUstep/SOGo/WebServerResources/;
	  allow all;
	  expires max;
   }

   location /SOGo/WebServerResources/
   {
	  alias /usr/local/lib/GNUstep/SOGo/WebServerResources/; 
	  allow all;
	  expires max;
   }

   location (^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$)
   {
	  alias /usr/local/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
	  expires max;
   }

   location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$)
   {
	  alias /usr/local/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
	  expires max;
   }
  }

Enable site:

sudo ln -s /etc/nginx/sites-available/sogo /etc/nginx/sites-enabled/

Test and start:

sudo nginx -t
sudo systemctl restart nginx

Troubleshooting

Failed to acquire channel for URL: mysql://sogo

You need a sogo database and a sogo database user.

ExecutionFailed REASON:Unknown column c_hascertificate

You need to upgrade the database frm 3.x to 4.x.

sudo /home/pi/SOGo/Scripts/sql-update-3.2.10_to_4.0.0-mysql.sh

Provide the sogo database user and password.

/var/run/sogo/sogo.pid No such file or directory

In my case the directory /var/run/sogo is an in-memory folder (tmpfs), it is gone after reboot resulting in the above error. This might be fixed in later editions, for now we will edit systemd sogo.service file to create the directory at startup of the sogo service.

In this script 'mkdir' is allowed to fail (directory exists), by prefixing it with '-'. The option 'PermissionsStartOnly=true' is added to execute the 'ExecStartPre' commands as root. The 'ExecStart' command will still be executed as the configured user ('sogo').

Note: we also lowered PREFORK from 3 to 2 here.

More info:

sudo nano /lib/systemd/system/sogo.service
[Unit]
Description=SOGo groupware server
After=network.target
After=mariadb.service

[Service]
Type=forking
User=sogo
Environment="PREFORK=2"
EnvironmentFile=-/etc/sysconfig/sogo
# Create /var/run/sogo, as root and ignore mkdir error
PermissionsStartOnly=true
# exec with prefix - to ignore errors
ExecStartPre=-/bin/mkdir /var/run/sogo
ExecStartPre=/bin/chown -R sogo:sogo /var/run/sogo
# Start sogo
ExecStart=/usr/local/sbin/sogod -WOWorkersCount ${PREFORK} -WOPidFile /var/run/sogo/sogo.pid -WOLogFile /var/log/so$
PIDFile=/var/run/sogo/sogo.pid

[Install]
WantedBy=multi-user.target

Restart the service:

sudo systemctl daemon-reload
sudo systemctl restart sogo
sudo systemctl status sogo

/etc/sogo/sogo.conf

This file needs to be readable by user 'sogo', but not by others. If you edit this file as root you need to reapply owner and group:

sudo chown -R sogo:sogo /etc/sogo

Logging

SOGo service status:

service sogo status

Config files:

sudo ls -l /etc/sogo

SOGo log:

sudo tail -20 /var/log/sogo/sogo.log


Apache2 modules (not updated)

Make sure you have enabled all necessary modules.

sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewrite
sudo a2enmod ssl

If there is some sort of problem with the web service it could pay off to temporary increase the log level. For example, with the Apache configuration file 'raspberrypi.conf':

sudo nano /etc/apache2/sites-available/raspberrypi.conf
...
LogLevel debug
...
sudo service apache2 restart

More info:

Note that locations have changed from /usr/ to usr/local/