-
-
Save penzoiders/105c6ac92912bd6b3367eef9d1201e04 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Install OnlyOffice Document Server on clean CentOS 7 base (may not work on non fresh systems) without asking anything | |
# HOW TO: just open a root terminal and brutally copy/paste this gist to your shell. | |
# SSL READY: featuring also a lazy-boy-style oneliner to get SSL cert from Let's Encrypt ( see bottom of this gist ) | |
curl -sL https://rpm.nodesource.com/setup_8.x | bash - | |
cat << EOF > /etc/yum.repos.d/nginx.repo | |
[nginx] | |
name=nginx repo | |
baseurl=http://nginx.org/packages/centos/7/\$basearch/ | |
gpgcheck=0 | |
enabled=1 | |
EOF | |
yum install -y nginx epel-release postgresql postgresql-server firewalld | |
cat << EOF > /etc/nginx/nginx.conf | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" ' | |
'\$status \$body_bytes_sent "\$http_referer" ' | |
'"\$http_user_agent" "\$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 65; | |
#gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
} | |
EOF | |
service postgresql initdb | |
systemctl enable postgresql | |
sed -i 's#host all all 127.0.0.1/32 ident#host all all 127.0.0.1/32 trust#;s#host all all ::1/128 ident#host all all ::1/128 trust#' /var/lib/pgsql/data/pg_hba.conf | |
systemctl restart postgresql | |
cd /tmp | |
sudo -u postgres psql -c "CREATE DATABASE onlyoffice;" | |
sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';" | |
sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;" | |
yum install -y redis rabbitmq-server | |
systemctl start redis | |
systemctl enable redis | |
systemctl start rabbitmq-server | |
systemctl enable rabbitmq-server | |
yum install -y http://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm | |
yum install -y onlyoffice-documentserver | |
systemctl start supervisord | |
systemctl enable supervisord | |
systemctl start nginx | |
systemctl enable nginx | |
cat /usr/bin/documentserver-configure.sh | sed 's/read -e/#read -e/' | sed 's/^read_saved_params$/DB_PWD=onlyoffice\nRABBITMQ_PWD=guest\nread_saved_params/' > /tmp/documentserver-configure-unattended.sh | |
bash /tmp/documentserver-configure-unattended.sh | |
systemctl start firewalld | |
systemctl enable firewalld | |
firewall-cmd --zone=public --add-service=http --permanent | |
firewall-cmd --reload | |
yum update -y | |
reboot | |
# You can secure it using Let's Encrypt SSL certificates with this single line here. | |
# NOTE: do this after reboot, you'll need to have a proper DNS record and ports 80 and 443 reachable from public IP | |
# you also need a DNS record to be published for that IP before launching the following command | |
# firewall-cmd --zone=public --add-service=https --permanent && firewall-cmd --reload && yum install -y python2-certbot-nginx && certbot --nginx certonly && systemctl stop nginx && cat /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver-ssl.conf.template | sed 's#{{SSL_CERTIFICATE_PATH}}#/etc/letsencrypt/live/'$(ls /etc/letsencrypt/live | head -n 1)'/fullchain.pem#' | sed 's#{{SSL_KEY_PATH}}#/etc/letsencrypt/live/'$(ls /etc/letsencrypt/live | head -n 1)'/privkey.pem#' > /etc/nginx/conf.d/onlyoffice-documentserver.conf && systemctl start nginx |
keep in mind that with nextcloud hub you can have the document server directly inside of nextcloud instance.
https://nextcloud.com/blog/how-to-install-onlyoffice-in-nextcloud-hub-and-new-integration-feature/
at present time it's not handling file revisions but worth using it to avoid running 2 servers.
Thank you very much for taking the time to reply to my question. I've used this script on a CentOS 7 minimal install and it appears to work with no errors reported as it runs except for a reference to line 35 which command not found. I tried accessing the site over port 80 using my IP but had an error page.
So I've issued the bash documentserver-configure.sh command again and confirmed the setup. Now when I reference the sever using my ip I can see that document server is now running. I do see your script running this bash script but for some reason my webpage wouldn't work unless I ran it again.
I very much appreciate you providing this script. for my usecase I do see that Nextcloud 18 does come with a documentserver app we can use for OnlyOffice. Sadly that app of OnlyOffice does not include a spellcheck and having an online document editing system without spellcheck won't work for me. Until the documentserver app has been updated with spellcheck I will prefer to use your script to install to install OnlyOffice on a separate server.
Do you know if your script could be used to upgrade OnlyOffice as well?
Thank you in advance for any advice you can provide me.
can't replicate the line 35 error you mention, anyway if running again fix the thing it's not a big deal.
to update the server you just need to do it via normal yum update
no other config or custom script required.
Appreciate the feedback! Thanks again for providing this script for all. Take care.
Hi,penzoiders, i've just install onlyoffice document server, but after reboot , i can't access to onlyoffice document server.
and when i excecute latest line for SSL , after complete . nginx can not starting :
cat: /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver-ssl.conf.template: No such file or directory
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
Please advice
in theory, if you skip last line, you should end up with a document server on port 80.
then it's up to you to proxy it and put an SSL.
This script is still valid for latest version on Centos7