onlyoffice源码编译

参考

官方编译文档

服务器配置

安装ubuntu18镜像虚拟机

  1. 内存:8G
  2. CPU:2核
  3. 硬盘:50G
  4. 网络:桥接模式

安装依赖项

编译依赖

sudo apt-get install -y python git

其他依赖

sudo apt install net-tools

配置代理

配置全局

  1. 使用http代理
  2. 不能用socks5代理(curl下载会失败)
  3. 需要分别配置HTTP代理和HTTPS代理
  4. 注意选择一个快的代理节点
  5. 直接全局配置生效
sudo vim /etc/profile

# 添加如下内容
export HTTP_PROXY=http://127.0.0.1:9910
export HTTPS_PROXY=http://127.0.0.1:9910

source /etc/profile

配置npm

# 添加
sudo npm config set proxy http://127.0.0.1:9910
sudo npm config set https-proxy http://127.0.0.1:9910
sudo npm config set registry https://registry.npmjs.org/

# 移除
sudo npm config delete proxy
sudo npm config delete https-proxy

下载编译工具

# 克隆仓库
git clone https://github.com/ONLYOFFICE/build_tools.git

# 执行安装脚本
cd build_tools/tools/linux
./automate.py server

编译安装

应该不会有什么大问题

如果出现安装包下载失败,就应该是代理问题

重新编译出现问题,一般可以清空对应目录重新执行编译

最后,编译成功(历时两天)

安装其他依赖

Nginx

安装
sudo apt-get install -y nginx
添加配置
# 删除默认站点配置
sudo rm -f /etc/nginx/sites-enabled/default

# 创建新的配置文件,添加如下内容
sudo vim /etc/nginx/sites-available/onlyoffice-documentserver

文件内容

map $http_host $this_host {
  "" $host;
  default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
  default $http_x_forwarded_proto;
  "" $scheme;
}
map $http_x_forwarded_host $the_host {
  default $http_x_forwarded_host;
  "" $this_host;
}
map $http_upgrade $proxy_connection {
  default upgrade;
  "" close;
}
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
server {
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_tokens off;
  rewrite ^\/OfficeWeb(\/apps\/.*)$ /web-apps$1 redirect;
  location / {
    proxy_pass http://localhost:8000;
    proxy_http_version 1.1;
  }
  location /spellchecker/ {
    proxy_pass http://localhost:8080/;
    proxy_http_version 1.1;
  }
}
配置生效
# 创建软连接
sudo ln -s \
/etc/nginx/sites-available/onlyoffice-documentserver \
/etc/nginx/sites-enabled/onlyoffice-documentserver
启动nginx
sudo nginx -s reload

# 查看启动结果
sudo netstat -nlp | grep 80
sudo ps -ef | grep nginx

postgreSQL

安装
sudo apt-get install -y 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;"
初始化数据
# 在根目录执行
cd

# 创建数据库
psql -hlocalhost -Uonlyoffice -d onlyoffice -f \
build_tools/out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
# 输入密码: onlyoffice

RabbitMQ

安装
sudo apt-get install -y rabbitmq-server
生成字体
cd 
cd build_tools/out/linux_64/onlyoffice/documentserver/
mkdir fonts

LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allfontsgen \
  --input="${PWD}/core-fonts" \
  --allfonts-web="${PWD}/sdkjs/common/AllFonts.js" \
  --allfonts="${PWD}/server/FileConverter/bin/AllFonts.js" \
  --images="${PWD}/sdkjs/common/Images" \
  --selection="${PWD}/server/FileConverter/bin/font_selection.bin" \
  --output-web='fonts' \
  --use-system="true"
生成演示主题
cd 
cd build_tools/out/linux_64/onlyoffice/documentserver/

LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allthemesgen \
  --converter-dir="${PWD}/server/FileConverter/bin"\
  --src="${PWD}/sdkjs/slide/themes"\
  --output="${PWD}/sdkjs/common/Images"

启动服务

前台启动

FileConverter

cd 
cd build_tools/out/linux_64/onlyoffice/documentserver/server/FileConverter

LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter

SpellChecker

cd 
cd build_tools/out/linux_64/onlyoffice/documentserver/server/SpellChecker

NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./spellchecker

DocService

cd 
cd build_tools/out/linux_64/onlyoffice/documentserver/server/DocService

NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice

测试应用

参考文档

https://api.onlyoffice.com/editors/try

你可能感兴趣的:(onlyoffice,数据库,linux,java,nginx)