背景
接任務部署一個wiki, 要求: java語言開發, 開源, 內網部署; 需要支持: 大文件上傳(300m左右), 所見即所得(wycwyg), 導出, LDAP, 評論與權限.
通過一個好用的 wiki compare (https://www.wikimatrix.org/) 網站對比后, 可用的只剩 XWIKI 與 JSPWIKI (https://jspwiki.apache.org/)了, 最終選定 XWIIKI.
XWIKI 官網 https://www.xwiki.org/xwiki/bin/view/Main/WebHome
准備工作
我使用的是java (version 1.8.0_111), tomcat(version 8.5), mysql(version 5.7.25) .
1, 使用 war 包部署, 選定當前的穩定版本下載https://www.xwiki.org/xwiki/bin/view/Download/, 下載 WAR Package for Servlet Container 和 XIP Addon Package for Offline Installs (有網無需下載, 在 Distribution Wizard 的 step 2 可以在線安裝).
2, 下載 org.xwiki.contrib.ldap_ldap-ui-x.x.x.xar (https://extensions.xwiki.org/xwiki/bin/view/Extension/LDAP/Application/), 對 LDAP 進行可視化配置.
3, 從xwiki的maven私服(https://nexus.xwiki.org/nexus )下載LDAP所需的jar包
<dependency>
<groupId>org.xwiki.contrib.ldap</groupId>
<artifactId>ldap-api</artifactId>
<version>x.x.x</version>
</dependency>
<dependency>
<groupId>org.xwiki.contrib.ldap</groupId>
<artifactId>ldap-authenticator</artifactId>
<version>x.x.x</version>
</dependency>
<dependency>
<groupId>com.novell.ldap</groupId>
<artifactId>jldap</artifactId>
<version>2009-10-07</version>
</dependency>
4, 准備MySQL JDBC Driver Jar, mysql-connector-java-x.x.x. jar 包
部署
1, 數據庫
# 建庫 create database xwiki default character set utf8;
# 授權
# grant all privileges on xwiki.* to xwiki@'%' identified by 'xwiki';
2, 把下載好的 war 包(war包改名為xwiki.war), 放入 tomcat 容器內, war包解壓.
把 mysql-connector-java-x.x.x. jar, ldap-api-x.x.x.jar, org.xwiki.contrib.ldap_ldap-authenticator-x.x.x.jar, jldap-2009-10-07.jar, 放入 ${tomcat}\webapps\xwiki\WEB-INF\lib\ 下.
ps: tomcat 啟動過程中如果日志出現: because there was insufficient free space ... consider increasing the maximum size of the cache. 修改 ${tomcat}\conf\context.xml, 添加 <Resources cachingAllowed="true" cacheMaxSize="100000" />;
如果不起作用, 修改 ${tomcat}\webapps\xwiki\META-INF\context.xml, 添加<Resources cachingAllowed="true" cacheMaxSize="100000" />
3, 修改 XWIKI 的配置, 在 ${tomcat}webapps\xwiki\WEB-INF\ 下
hibernate.cfg.xml
更換 database 相關配置, 注釋掉 Configuration for the default database . 打開 MySQL configuration , 修改 Mysql 的 connection.url, connection.username, connection.password.
xwiki.cfg
啟用 superadmin, 打開 # xwiki.superadminpassword=system.
打開並修改LDAP的設置, xwiki.authentication.authclass=org.xwiki.contrib.ldap.XWikiLDAPAuthServiceImpl
設置附件存儲方式:
xwiki.store.attachment.hint=file
xwiki.store.attachment.versioning.hint=file
xwiki.store.attachment.recyclebin.hint=file
xwiki.properties
設置附件存儲目錄, 打開 #environment.permanentDirectory=/var/local/xwiki/
4, 把 xwiki-platform-distribution-flavor-xip-x.x.x.xip (可改為zip進行解壓, 其實就是一個zip包), 解壓放入 xwiki.properties中配置的${environment.permanentDirectory}\extension\repository\下. 重啟tomcat.
ps: tomcat啟動后, 會提示從 https://nexus.xwiki.org 獲取 findbugs 等jar包失敗等報錯信息(因為我是無外網安裝, 有網情況下不會出現), 無視就好了.
5, 瀏覽器中輸入 ip:port , 會進行 xwiki 初始化, 初始化完成后, 進入 Distribution Wizard 的 頁面, 在 step2(其余step很簡單) 等待加載出離線的flavor, 下邊是官方給的Installation Guide(https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/).
Installing without internet connection XIP package Since 9.5 a XIP package is provided for the Standard flavor. This is actually a zip file containing the required XWiki extensions for both the main wiki and subwikis, in the same format than the local extensions repository. download it (use the exact same version of the XIP package as the version of XWiki you have) Unzip it (rename it to .zip if your zip tool does not recognize it) in the folder <permanentdirectory>/extension/repository
(if you get complains about already existing files don't overwrite them) Restart XWiki if it was running Resume standard installation, this time it will find the flavor locally
step2 如圖所示(我已經安裝好了, 圖是我在網上找的, 版本請忽略), 安裝flavor.
6, 配置LDAP. 官網指示(https://extensions.xwiki.org/xwiki/bin/view/Extension/LDAP/Application/) 不靠譜
6.1, superadmin登錄后, 進入 http://ip:port/bin/admin/XWiki/XWikiPreferences, 依次點擊 content -> import->upload 下載好的org.xwiki.contrib.ldap_ldap-ui-x.x.x.xar, 最后點擊 右下的 import 按鈕
6.2, import 成功后, 可以在 http://ip:port/bin/admin/XWiki/XWikiPreferences 的 Other -> LDAP 中 進行可視化配置, 我在配置了 紅框中的屬性后, LDAP可以正常使用了.
``` sh
# 修改tomcat
```