OnlyOffice驗證(一)DocumentServer編譯驗證
資源準備
Ubuntu16.04桌面版
??驗證用的版本[ubuntu-16機接上傳ubuntu.04.7-desktop-amd67131.iso,(別用高版本!試過20.04耽誤兩三天,差點放棄了),使用桌面版是為了后面好編輯。
代理工具
??主要是為了資源下載,編譯期間需要配置全局代理、git代理和npm代理。全局代理主要是apt和curl用,此處注意npm先別配鏡像源讓它走代理,apt也不要配置鏡像源。(備注:192.168.95.130:7890是代理服務(wù)器,win11宿主機192.168.95.130,虛擬機192.168.95.133。模式是NAT模式。)
VMwareWorkstation17
??如果是Win11最好還是用這個版本,VMware16好像兼容有點問題。要是不藍屏此處可省略。
編譯
安裝Python
??如果使用的16.04和上面的版本一樣的話可以不用安裝,本身自帶Python 2.7.12
和Python 3.5.2
。
sudo apt-get install -y python
安裝Git
??不配置代理正常也能安裝上,就是慢點。
sudo apt-get install -y git
??安裝后給git配置代理。好處是能提升點下載速度,還有就是到V8模塊編譯的時候會下載depot_tools
,連不上google肯定編譯失敗。
git config --global http.proxy http://192.168.95.130:7890
git config --global https.proxy socks5://192.168.95.130:7890
??此處防止大文件拉取失敗又加了點配置,意義并不大網(wǎng)絡(luò)不穩(wěn)定該斷開還是會斷開。
root@t16:/# git config --list
http.postbuffer=524288000
http.lowspeedtime=60000
http.proxy=http://192.168.95.130:7890
core.compression=-1
https.postbuffer=524288000
https.lowspeedtime=60000
https.proxy=socks5://192.168.95.130:7890
配置全局代理
??修改環(huán)境變量
vim /etc/profile
??vim默認沒有可以安裝一個:
sudo apt-get install -y vim
??追加環(huán)境變量,然后:wq
保存退出
export ALL_PROXY=socks5://192.168.95.130:7890
export HTTP_PROXY=http://192.168.95.130:7890
export HTTPS_PROXY=http://192.168.95.130:7890
??使環(huán)境變量立即生效
source /etc/profile
??如果還不生效就重啟虛擬機(reboot
)。
下載ONLYOFFICE/build_tools
??默認就是master:
git clone https://github.com/ONLYOFFICE/build_tools.git
??指定版本(未驗證):
git clone --depth=1 --recursive --branch v7.3.2.3 https://github.com/ONLYOFFICE/build_tools.git
編譯前準備工作
??下完build_tool
后,執(zhí)行cd ./build_tools/tools/linux
切換目錄,不要著急去執(zhí)行automate.py
,可以看到同級目錄下有個deps.py
,然后automate.py
執(zhí)行的開始就是檢查環(huán)境然后調(diào)用deps.py
去安裝基礎(chǔ)環(huán)境:
??所以可以先執(zhí)行deps.py
安裝基礎(chǔ)環(huán)境(安裝完了創(chuàng)建個快照),保證基礎(chǔ)環(huán)境沒有問題再去構(gòu)建。然而先別著急去執(zhí)行,還需要修改個地方。要不然curl下載https資源的時候會報錯。所以還需要改一個文件:
??cd ./build_tools/scripts
目錄修改base.py
中的download()
方法
??修改前
# common apps
def download(url, dst):
return cmd_exe("curl", ["-L", "-o", dst, url])
??修改后
# common apps
def download(url, dst):
return cmd_exe("curl", ["-k", "-L", "-o", dst, url])
安裝基礎(chǔ)環(huán)境
??切換目錄到build_tools/tools/linux
下,執(zhí)行deps.py
可執(zhí)行文件。隨后將會進行進出環(huán)境的安裝,包括NodeJS
和Java
環(huán)境。經(jīng)過漫長的等待如果成功就會生成下圖標注的文件且內(nèi)容為complete。
??如果中途報錯且node已經(jīng)安裝完。則可以先配置npm代理。
??node環(huán)境檢查:
root@t16:/opt/build_master/build_tools/tools/linux# node -v
v10.24.1
root@t16:/opt/build_master/build_tools/tools/linux# npm -v
6.14.12
??配置npm代理:
sudo npm config set proxy http://192.168.95.130:7890
sudo npm config set https-proxy http://192.168.95.130:7890
??如果一切順利最終Java也安裝完成:
root@t16:/opt/build_master/build_tools/tools/linux# java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
執(zhí)行構(gòu)建
??切換目錄到build_tools/tools/linux
下,執(zhí)行automate.py
可執(zhí)行文件。
./automate.py server
??繼續(xù)慢慢等待幾個小時,中途可以睡一覺(做好編譯失敗的心理準備,如果失敗了就刪了除了build_tools的源碼再來一遍)編譯結(jié)果在build_tools/out
下:
安裝運行環(huán)境
??此處完全按照官網(wǎng)的方式安裝配置,先不用考慮Nginx其它方式的部署,數(shù)據(jù)庫切換Mysql,Rabbit連接其它的服務(wù)器的問題??傊褪且活D復制粘貼,先運行起來看看效果再說:
安裝Nginx
sudo apt-get install nginx
??刪除默認配置文件
sudo rm -f /etc/nginx/sites-enabled/default
??創(chuàng)建配置文件
sudo vim /etc/nginx/sites-available/onlyoffice-documentserver
??配置內(nèi)容如下
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;
}
}
??創(chuàng)建軟連接
sudo ln -s /etc/nginx/sites-available/onlyoffice-documentserver /etc/nginx/sites-enabled/onlyoffice-documentserver
??重啟Nginx使配置生效
sudo nginx -s reload
安裝PostgreSql
sudo apt-get install postgresql
??創(chuàng)建數(shù)據(jù)庫和用戶
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;"
??導入數(shù)據(jù)庫腳本創(chuàng)建相關(guān)的表。注意腳本的目錄,為了方便參考此處貼出絕對目錄
psql -hlocalhost -Uonlyoffice -d onlyoffice -f /opt/build_master/build_tools/out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
安裝RabbitMQ
sudo apt-get install rabbitmq-server
??執(zhí)行完上面的腳本就完事了,可以執(zhí)行systemctl status rabbitmq-server
看下服務(wù)的狀態(tài):
初始化數(shù)據(jù)
??只需要執(zhí)行一次就行,往后直接啟動就行了(如果是重新編譯,需要重新初始化數(shù)據(jù),因為編譯數(shù)據(jù)是重新生成的,沒有上一次的初始化數(shù)據(jù)了)
??注意目錄,以編譯結(jié)果目錄為主,下圖為/opt/build_master/build_tools/out/linux_64/onlyoffice/documentserver
目錄結(jié)構(gòu)(※fonts目錄是生成字體數(shù)據(jù)時創(chuàng)建的):
生成字體數(shù)據(jù)
cd /opt/build_master/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 /opt/build_master/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"
運行服務(wù)
??官網(wǎng)提供的示例都是前臺啟動程序,這里為了方便可以先起兩個會話分別啟動文檔服務(wù)和轉(zhuǎn)換服務(wù),先切換目錄到/opt/build_master/build_tools/out/linux_64/onlyoffice/documentserver/server
:
??此處可以把全局代理關(guān)了,直接編輯vim /etc/profile
將代理都注釋掉。然后source /etc/profile
使其生效。以防萬一還是重啟比較保險。不用擔心Nginx
、PostgreSql
和RabbitMQ
都是自啟的。
啟動轉(zhuǎn)換服務(wù)
cd out/linux_64/onlyoffice/documentserver/server/FileConverter
LD_LIBRARY_PATH=$PWD/bin \
NODE_ENV=development-linux \
NODE_CONFIG_DIR=$PWD/../Common/config \
./converter
啟動文檔服務(wù)
cd out/linux_64/onlyoffice/documentserver/server/DocService
NODE_ENV=development-linux \
NODE_CONFIG_DIR=$PWD/../Common/config \
./docservice
效果驗證
基本驗證
??因為Nginx直接配置的80端口,所以直接http訪問服務(wù)IP即可。welcome歡迎頁這時候還沒有配置,可以先訪問api.js試試。
??請求http://192.168.95.133/web-apps/apps/api/documents/api.js
:
??除了這種方式還可以試試別的接口,比如通過Postman請求版本號看看。
??請求http://192.168.95.133/coauthoring/CommandService.ashx
:
預覽文檔
??基本驗證只是看看服務(wù)運行沒運行起來。畢竟最終還是要看文檔在線預覽的效果。此處除了example還有什么方式可以快速查看效果?~~~~~還真有,官網(wǎng)提供了一個示例工程,效果還十分的不錯。
- 示例說明:https://api.onlyoffice.com/editors/vue
??還好有Vue的,畢竟對React不熟,直接下載git clone https://github.com/ONLYOFFICE/document-editor-vue
。
同步依賴包要是npm下的慢可以考慮裝個yarn。
??找到default.json
改一下服務(wù)部署的IP地址。隨后啟動項目看下在線預覽的效果:
Word效果
Excel效果
PowerPoint效果
參考資料
- https://blog.csdn.net/lanyingtianshiabc/article/details/108534623
- https://blog.csdn.net/huqngqing/article/details/114635793
- https://github.com/ONLYOFFICE/build_tools
??編譯步驟主要都是官網(wǎng)提供的步驟,以上資料的評論很有參考價值。文章來源:http://www.zghlxwxcb.cn/news/detail-791785.html
- https://www.songbin.top/search?kw=onlyoffice
??這個資料基本就是最全的了,非常具有參考的價值。文章來源地址http://www.zghlxwxcb.cn/news/detail-791785.html
相關(guān)總結(jié)
- 《OnlyOffice驗證(一)DocumentServer編譯驗證》
- 《OnlyOffice驗證(二)在Centos7上部署OnlyOffice編譯結(jié)果》
- 《OnlyOffice驗證(三)OnlyOffice編譯結(jié)果自制Docker鏡像》
- 《OnlyOffice驗證(四)MoblieWeb編譯》
到了這里,關(guān)于OnlyOffice驗證(一)DocumentServer編譯驗證的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!