LibreOffice Online mit Nextcloud unter Arch Linux mit Let’s Encrypt Zertifikat - Schnellanleitung ohne Docker (aktualisiert 02.09.2016)

Ich habe hier mal zusammengefasst, wie ich zu meiner lauffähigen Installation gekommen bin.

(nextcloud, mariadb, php7, apache, …)

Ich habe meist den Benutzer “http” verwendet. Warum? Weil es ihn gibt! :yum: …und LibreOffice nicht als “root” gebaut werden konnte… Man hätte natürlich auch jeden anderen Benutzer zum Bauen nehmen können…

LibreOfficeOnline unter ArchLinux mit Let’s Encrypt Zertifikat (Schnellanleitung):

angemeldet war ich als “root”, was mir einige "sudo"s erspart…

Damit es beim Bauen von LibreOffice etwas schneller geht, habe ich noch ccache installiert und die Option --with-parallelism hinzugefügt.

Ich habe einen neuen Benutzer und eine Gruppe “lool” erstellt, unter dem dann der “loolwsd” laufen soll…

useradd -U -M -d /dev/null -s /bin/false lool


Abhängigkeiten:

pacman -S --needed \
apr boost cairo ccache clucene cups curl expat gdb glew gperf graphite \
gtk3 harfbuzz hyphen icu lcms2 libabw libatomic_ops libcap libcap-ng \
libcdr libcmis libe-book libetonyek libexttextcat libixion libjpeg \
liblangtag libldap libmspub libmwaw libodfgen liborcus libpagemaker \
libpng librevenge libvisio libwpd libwpg libwps libxml2 lpsolve neon nss \
openssl poppler python redland serf unixodbc zlib translate-toolkit \
python-polib python2-polib

Es sind bestimmt nicht alle libs und Pakete notwendig, aber das ist mir an dieser Stelle erst einmal egal. :wink:
Außerdem müssen dafür weniger Bestandteile beim LibreOffice gebaut werden, da sie im System schon vorhanden sind.

Natürlich sind noch einige weitere Pakete notwendig, um z.B. ein “make” verwenden zu können. Diese habe ich hier aber nicht extra aufgeführt, da sie meist unter Arch sowieso installiert sind…soll ja hier auch nur eine Schnellanleitung sein…:sunglasses:

aus dem AUR:

pacaur -y poco-git



LibreOffice bauen:
(Welche LibreOffice Version man verwenden möchte, kann man ja über die Auswahl der “git-branch” entscheiden. Ich habe die “distro/collabora/cp-5.1” geklont, da hier “Impress” besser funktionier als in der master-branch.)

cd /opt; \
git clone -b "distro/collabora/cp-5.1" "https://github.com/LibreOffice/core.git" "LibreOfficeCore_co_git"; \
cd /opt/LibreOfficeCore_co_git; \
cat configure.ac | grep -E "AC_INIT\(\["

Zielverzeichnis der Libre-Installation und einige andere “Sachen” festlegen:

export LOIPATH=“CollaboraOffice_5.1.10.4”;
export LOOLDIR=“lool_co”;
export LOOLGITDIR=“lool_co_git”;
export LOBINDIR=“collaboraoffice”;
export LOOLUSER=“lool”;
mkdir /opt/${LOIPATH}


chown -R http:http /opt/LibreOfficeCore_co_git; \
rm -rf `echo ~http/.ccache`; \
mkdir `echo ~http/.ccache`; \
chown -R http:http `echo ~http/.ccache`; \
sudo -u http ccache --max-size 32G

./autogen.sh --help | less

  --enable-mergelibs      Enables linking of big, merged, library.
                          Experimental feature, tested only for Linux at some
                          stage in history, but possibly does not work even
                          for Linux any more. This will link a core set of
                          libraries into libmerged.

Also habe ich diese Option mal lieber nicht verwendet.:slight_smile: …auch wenn einige Distri-Pakete so gebaut sind bzw. waren.


sudo -u http ./autogen.sh --prefix=/opt/$LOIPATH \
--with-lang='de' \
--with-parallelism \
--with-help \
--with-myspell-dicts \
--with-alloc=system \
--without-java \
--without-system-dicts \
--disable-dconf \
--disable-odk \
--disable-firebird-sdbc \
--disable-postgresql-sdbc \
--enable-release-build=yes \
--enable-python=system \
--enable-hardlink-deliver \
--with-system-apr \
--with-system-boost=yes \
--with-system-cairo \
--with-system-clucene \
--with-system-curl \
--with-system-expat \
--with-system-graphite \
--with-system-harfbuzz \
--with-system-icu \
--with-system-jpeg \
--with-system-libabw \
--with-system-libcdr \
--with-system-libebook \
--with-system-libetonyek \
--with-system-liblangtag \
--with-system-libmspub \
--with-system-libmwaw \
--with-system-libodfgen \
--with-system-libpagemaker \
--with-system-librevenge \
--with-system-libvisio \
--with-system-libwpd \
--with-system-libwpg \
--with-system-libwps \
--with-system-lpsolve \
--with-system-libcmis \
--with-system-libexttextcat \
--with-system-lcms2 \
--with-system-libatomic_ops \
--with-system-libpng \
--with-system-libxml \
--with-system-neon \
--with-system-nss \
--with-system-odbc \
--with-system-openldap \
--with-system-openssl \
--with-system-poppler \
--with-system-redland \
--with-system-serf \
--with-system-zlib

echo Start: `date` > time.txt; \
sudo -u http make; \
echo " Ende:" `date` >> time.txt; \
echo;echo; \
cat time.txt; \
echo; \
du -hs /opt/LibreOfficeCore_co_git; \
du -hs `echo ~http/.ccache`; \
echo; \
sudo -u http ccache -s; \
echo

Zeit für make + Download beim ersten Durchlauf von make:
Die Dauer ist stark abhängig von der Maschine und der Internetanbindung. Durch den Cache würde aber ein nochmaliges “make” extrem schneller laufen, wenn es durch Optionsänderungen bei autogen.sh notwendig wäre.

Start: Fr 15. Jul 12:17:26 CEST 2016
 Ende: Fr 15. Jul 13:42:27 CEST 2016

8,8G    /opt/LibreOfficeCore_co_git
1,7G    /srv/http/.ccache

cache directory                     /srv/http/.ccache
primary config                      /srv/http/.ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                 10131
cache hit (preprocessed)             182
cache miss                          9859
called for link                     1108
called for preprocessing             476
compile failed                        48
preprocessor error                    30
bad compiler arguments               106
unsupported source language            2
autoconf compile/link                530
unsupported compiler option          696
no input file                        288
files in cache                     29666
cache size                           1.7 GB
max cache size                      32.0 GB

make install


LibreOffice Online WebSocketServer

Wenn vorhanden, dann vorherige Installation sichern:

systemctl stop loolwsd

cd /opt; \
tar -cf ${LOOLDIR}.tar ${LOOLDIR}; \
rm -rf /opt/${LOOLDIR}

Rücksichern bei Fehlern usw.:

rm -rf /opt/${LOOLDIR}; cd /opt; tar -xf ${LOOLDIR}.tar ${LOOLDIR}

Sollte dieser Fall eintreten, dann muss nach der Wiederherstellung das Systemtemplate für die “jails” - wie weiter unten beschrieben - neu erzeugt werden. (inkl. setcap) Außer man hat nicht tar sondern mv verwendet. Denn bei der Verwendung von mv bleiben die belegten “inodes” die gleichen.


Vorbereitung und Bauen:

cd /opt; \
git clone "https://github.com/LibreOffice/online.git" ${LOOLGITDIR}; \
cd /opt/${LOOLGITDIR}/loolwsd; \
libtoolize; \
aclocal; \
automake --add-missing; \
autoreconf; \
autoheader

./configure \
--prefix=/opt/${LOOLDIR}/loolwsd \
--bindir=/opt/${LOOLDIR}/loolwsd \
--sysconfdir=/opt/${LOOLDIR}/loolwsd/etc \
--enable-silent-rules \
--with-lokit-path=/opt/${LOOLGITDIR}/loolwsd/bundled/include \
--with-lo-path=/opt/${LOIPATH}/lib/${LOBINDIR}

make;make install


Let’sEnCrypt Zertifikat einbinden:

rm -rf /etc/loolwsd; \
mkdir /etc/loolwsd; \
cp -L /etc/letsencrypt/live/ebh-senzig.de/cert.pem /etc/loolwsd/cert.pem; \
cp -L /etc/letsencrypt/live/ebh-senzig.de/chain.pem /etc/loolwsd/ca-chain.cert.pem; \
cp -L /etc/letsencrypt/live/ebh-senzig.de/privkey.pem /etc/loolwsd/key.pem

Nach einem “renew” bzw. einer Neuinstallation von Zertifikaten sollte dieser Schritt natürlich wiederholt werden.


Clientteil (loleaflet)

cd /opt/${LOOLGITDIR}/loleaflet; \
export LOLCLIENT="loleaflet-"`grep "^VERSION=" Makefile | sed 's/VERSION=//'`; \
make dist; \
tar -xzf ${LOLCLIENT}.tar.gz -C /opt/${LOOLDIR}/; \
mv /opt/${LOOLDIR}/${LOLCLIENT} /opt/${LOOLDIR}/loleaflet; \
unset LOLCLIENT

Systemtemplate für jails erzeugen:

setcap cap_fowner,cap_mknod,cap_sys_chroot=ep /opt/${LOOLDIR}/loolwsd/loolforkit; \
setcap cap_sys_admin=ep /opt/${LOOLDIR}/loolwsd/loolmount; \
mkdir -p /opt/${LOOLDIR}/loolwsd/var/cache/loolwsd/; \
mkdir -p /opt/${LOOLDIR}/jails/; \
chown -R ${LOOLUSER}:${LOOLUSER} /opt/${LOOLDIR}/loolwsd/var/cache/loolwsd/; \
chown -R ${LOOLUSER}:${LOOLUSER} /opt/${LOOLDIR}/jails/; \
rm -rf /opt/${LOOLDIR}/loolwsd/systemplate; \
/opt/${LOOLDIR}/loolwsd/loolwsd-systemplate-setup "/opt/${LOOLDIR}/loolwsd/systemplate" "/opt/${LOIPATH}/lib/${LOBINDIR}/" && \
touch /opt/${LOOLDIR}/loolwsd/systemplate/system_stamp; \
chown -R ${LOOLUSER}:${LOOLUSER} /opt/${LOOLDIR}/loolwsd/systemplate

loolwsd testen

systemctl restart httpd

sudo -u lool /opt/${LOOLDIR}/loolwsd/loolwsd \
--o:lo_template_path=/opt/${LOIPATH}/lib/${LOBINDIR} \
--o:sys_template_path=/opt/${LOOLDIR}/loolwsd/systemplate \
--o:child_root_path=/opt/${LOOLDIR}/jails \
--o:file_server_root_path=/opt/${LOOLDIR} 

/etc/systemd/system/loolwsd.service erzeugen
Hier muss natürlich der genau Pfad zur Libre-Installation angegeben werden. $LOIPATH und die anderen “exports” sind ja irgendwann wieder verschwunden. :innocent:

[Unit]
Description=LibreOffice On-Line WebSocket Daemon
After=network.target

[Service]
ExecStart=/opt/lool_co/loolwsd/loolwsd --version --o:sys_template_path=/opt/lool_co/loolwsd/systemplate --o:lo_template_path=/opt/CollaboraOffice_5.1.10.4/lib/collaboraoffice --o:child_root_path=/opt/lool_co/jails --o:file_server_root_path=/opt/lool_co

User=lool
KillMode=control-group
Restart=always

[Install]
WantedBy=multi-user.target

Läuft der loolwsd ?

netstat -lntp | grep 9980

sollte zeigen

tcp 0 0 0.0.0.0:9980 0.0.0.0:* LISTEN 6623/loolwsd

Die PID ist natürlich bestimmt nicht die gleiche… (6623)


Aufräumen wenn alles funktioniert und die Quellen (wirklich) nicht mehr benötigt werden:

rm -rf /opt/LibreOfficeCore_co_git; \
rm -rf `echo ~http/.ccache`; \
rm -f /opt/${LOOLDIR}.tar; \
rm -rf /opt/${LOOLGITDIR}; \
unset LOIPATH; \
unset LOOLDIR; \
unset LOOLGITDIR; \
unset LOOLUSER; \
unset LOBINDIR

Der ccache von http sollte natürlich nicht gelöscht werden, wenn man ihn für ein weiteres “make” verwenden will. :innocent: Was natürlich auch für die geladenen git-Verzeichnisse zutrifft…



Nexcloud

Die App für Nextcloud ist ja mittlerweile schon in Nextcloud enthalten. Ihr muss nur noch gesagt werden, wo der loolwsd lauscht… Bitte nicht gemainsam mit der “documents-app” verwenden (sonst müssen sich zwei apps um die mime-types streiten)… Die aktuelle app-Version kann natürlich auch über “GIT” bezogen werden und muss dann nach den dortigen Anweisungen erstellt und eingebunden werden.

sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ app:disable documents; \
sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ app:enable richdocuments; \
sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ config:app:set --value='https://EURE_NEXTCLOUD:9980' richdocuments wopi_url

oder:

sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ app:disable documents; \
sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ app:enable richdocuments; \
sudo -u http php /PFAD_ZUR_NEXTCLOUD/occ config:app:set --value='https://EURE_NEXTCLOUD' richdocuments wopi_url

bei der Verwendung der WebServerProxyFunktionalität…

Port 9980 (wenn man beim Standard bleibt) muss von außen erreichbar sein (siehe iptables, portforwarding usw.)

es sei denn…

UPDATE: Hatte ich ganz vergessen… Natürlich muss man das Port nicht zwingend öffnen. Man kann auch seinen Apache (in meinem Fall) oder jeden anderen Webserver so konfigurieren, dass er seine - wenn denn vorhanden - Proxy-Funktionalität verwendet, um auf den “loolwsd” zuzugreifen.

Hier mal ein Auszug aus meiner VirtualHost-Konfiguration für NextCloud:

.
.
.

####### PROXY GLOBALS ###################################################################

SSLProxyEngine On
ProxyVia On
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
AllowEncodedSlashes On
SSLProxyVerify None
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off

####### LOOLWSD #########################################################################

# static html, js, images, etc. served from loolwsd
# loleaflet is the client part of LibreOffice Online
ProxyPass           /loleaflet https://127.0.0.1:9980/loleaflet retry=0
ProxyPassReverse    /loleaflet https://127.0.0.1:9980/loleaflet

# WOPI discovery URL
ProxyPass           /hosting/discovery https://127.0.0.1:9980/hosting/discovery retry=0
ProxyPassReverse    /hosting/discovery https://127.0.0.1:9980/hosting/discovery

# Main websocket
ProxyPass   /lool/ws      wss://127.0.0.1:9980/lool/ws

# Admin Console websocket
ProxyPass   /lool/adminws wss://127.0.0.1:9980/lool/adminws

# Download as, Fullscreen presentation and Image upload operations
ProxyPass           /lool https://127.0.0.1:9980/lool
ProxyPassReverse    /lool https://127.0.0.1:9980/lool

####### WEBRTC ##########################################################################

<Location /webrtc>
        ProxyPass https://127.0.0.1:8443/webrtc
        ProxyPassReverse /
</Location>

<Location /webrtc/ws>
      ProxyPass wss://127.0.0.1:8443/webrtc/ws
</Location>

#########################################################################################

.
.
.

Dieses Vorgehen setzt natürlich entsprechende ApacheModule voraus. :wink: Dies entsprich der “hier” beschriebenen Variante (nur eben ganz ohne Docker). Deshalb habe ich mir alle Angaben zu den notwendigen Modulen gespart. Denn diese sind dort ja schon genau aufgeführt.


Danach lief bei mir LOL in der NextCloud. Anregungen und Feedbacks sind natürlich willkommen.