本文讲解如何在Ubuntu/Debian系统上部ONLYOFFICE Document Server。
1. 安装依赖
ONLYOFFICE Document Server使用NGINX和PostgreSQL作为数据库,首先先安装依赖。
安装和配置PostgreSQL:
输入命令安装
sudo apt-get install postgresql
安装后,搭建postgresql数据库和用户:
sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
安装rabbitmq
sudo apt-get install rabbitmq-server
安装Redis
sudo apt-get install redis-server
安装nginx
sudo apt install nginx
修改ONLYOFFICE Document Server的默认端口
Document Server的默认使用80端口,如果要和Apache在同一服务器上的话,80端口是不能使用的。
使用以下命令修改为8000端口:
echo onlyoffice-documentserver onlyoffice/ds-port select 8000 | sudo debconf-set-selections
2. 安装ONLYOFFICE Document Server
添加GPG密钥:
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
gpg --no-default-keyring --keyring gnupg-ring:/tmp/onlyoffice.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
chmod 644 /tmp/onlyoffice.gpg
sudo chown root:root /tmp/onlyoffice.gpg
sudo mv /tmp/onlyoffice.gpg /etc/apt/trusted.gpg.d/
添加ONLYOFFICE 的apt源并更新源:
sudo echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
sudo apt-get update
安装ttf-mscorefonts-installer
sudo apt-get install ttf-mscorefonts-installer
关闭apache2再安装ONLYOFFICE Document Server
sudo systemctl stop apache2
sudo apt-get install onlyoffice-documentserver
安装过程中输入上文设置的PostgreSQL密码:onlyoffice。
当询问是否接受EULA协议是,选择“OK”。
3. 为Nginx开启HTTPS
生成文件夹并把SSL证书保存
sudo mkdir /etc/nginx/CA
sudo chmod -R 777 /etc/nginx/CA
sudo mv 你的SSL证书 /etc/nginx/CA
删除nginx原来配置
sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default_old
修改nginx配置
sudo vi /etc/nginx/conf.d/ds.conf
删除所有内容,更改为以下代码,并添加你的SSL证书的绝对路径
include /etc/nginx/includes/http-common.conf;
server {
listen 0.0.0.0:8000 ssl;
listen [::]:8000 ssl default_server;
server_tokens off;
root /usr/share/nginx/html;
ssl_certificate /etc/nginx/CA/你的SSL证书;
ssl_certificate_key /etc/nginx/CA/你的SSL证书;
ssl_verify_client off;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=31536000;
add_header X-Content-Type-Options nosniff;
include /etc/nginx/includes/ds-*.conf;
}
重启Nginx及Apache
sudo service nginx restart
sudo service apache2 restart
打开浏览器输入
https://你的域名:8000
Enjoy