一、Xwiki簡介
XWiki是一個由Java編寫的基於LGPL協議釋出的開源wiki和應用平臺。XWiki是一款基於java所編寫的wiki,它可以執行在如Tomcat,Jetty,JBoss,WebLogic,WebSphere等Servlet容器上並利用關係型資料庫(HSQL, MySQL等)來儲存資料,大部分資料庫產品都可以在XWiki上執行但是必須進行正確的設定。
中文網站:http://www.xwikichina.com/xwiki/bin/view/Main/
二、Xwiki安裝
1.軟體下載
http://download.forge.ow2.org/xwiki/xwiki-10.1.war
三種安裝方式,本文采用的war包安裝
使用已包含Servlet容器(Jetty)和資料庫(HSQL)並帶有預設wiki首頁的打包版本的XWiki安裝。如果你是新手並且想快速嘗試XWiki的功能,推薦使用這種方式安裝。
使用war包來安裝XWiki,但是你必須設定好你的Servlet容器和資料庫讓XWiki工作起來。
使用deb包安裝最新版本的XWiki和相關的外掛。
2.安裝需求
jdk1.8
mysql-connector-java-5.1.34.jar
tapache-tomcat-8.5.29.tar.gz
mysql
xwiki-10.1.war
3.apache和xwiki安裝
下載地址(8.5.29):http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29.tar.gz
解壓縮:tar -xzvf apache-tomcat-8.5.29.tar.gz
安裝: mv apache-tomcat-8.5.29 /usr/local/apache
cd /usr/local/apache/webapps
mkidr xwiki
unzip xwiki-10.1.war -d /usr/local/apache/webapps/xwiki/
配置:編輯tomcat的server.xml修改8080埠描述設定編碼為UTF8,並允許gzip壓縮
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
compression="on"
compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/css,text/javascript,application/x-javascript"/>
配置JVM的記憶體大小和安裝路徑
如果是通過yum安裝的tomcat需要修改如/etc/tomcat6/tomcat6.conf 這個檔案
如果是使用的tomcat原始碼包安裝,則修改bin/catalina.sh 這個檔案
JAVA_OPTS="-Xmx300m -XX:MaxPermSize=196m"
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64"
配置資料庫,新建xwiki的資料庫並授權
create database xwiki default character set utf8 collate utf8_bin;
grant all privileges on xwiki.* to xwiki@'%' identified by 'xwiki';
下載MySQL JDBC Driver Jar放到/usr/local/apache/webapps/xwiki/WEB-INF/lib/目錄下
wget http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar
cp -rp mysql-connector-java-5.1.34.jar /usr/local/apache/webapps/xwiki/WEB-INF/lib/
配置xwiki應用
cd /usr/local/apache/webapps/xwiki/WEB-INF
vi hibernate.cfg.xml (註釋掉無用的資料來源配置)
<property name="connection.url">jdbc:mysql://localhost/xwiki?useSSL=false</property>
<property name="connection.username">xwiki</property>
<property name="connection.password">xwiki</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="connection.charSet">UTF-8</property>
<property name="connection.characterEncoding">UTF-8</property>
<property name="connection.useUnicode">true</property>
<property name="dbcp.poolPreparedStatements">true</property>
<property name="dbcp.maxOpenPreparedStatements">20</property>
<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>
編輯xwiki.cfg
vi xwiki.cfg
xwiki.readonly=no
xwiki.encoding=UTF-8
xwiki.store.main.hint=hibernate
xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml
xwiki.superadminpassword=system
配置office server
yum install libreoffice libreoffice-headless
XWIKI字符集編碼配置
vi web.xml
encoding="UTF-8"
4.xwiki初始化
使用. /usr/local/apache/bin/startup.sh 啟動tomcat後,通過http://ipaddr:8080/xwiki做xwiki初始化工作
設定中文
三、Xwiki管理
四、附錄
1、安裝錯誤資訊01
錯誤資訊:根據檢視tomcat的啟動日誌 /usr/local/apache_bak/logs/catalina.2018-03-25.log , /usr/local/apache_bak/logs/catalina.out
Mar 25, 2018 9:44:05 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile INFO: validateJarFile(/usr/local/apache/webapps/xwiki/WEB-INF/lib/javax.el-3.0.0.jar) - jar not loaded. See Servlet Spec 3 .0, section 10.7.2. Offending class: javax/el/Expression.class Mar 25, 2018 9:44:22 AM org.apache.catalina.startup.TldConfig execute INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete lis t of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup tim e and JSP compilation time.
處理方法:
根據錯誤資訊,根據查詢原因大致是因為tomcat7以上啟動需要檢查tld,這裡開啟debug模式檢視具體需要檢查哪些jar包,然後跳過處理
開啟tld檢查jar日誌記錄 vi /usr/local/apache/conf/logging.properties org.apache.jasper.servlet.TldScanner.level = FINE 然後關閉tomcat,啟動並檢查catalina.out egrep "No TLD files were found in" catalina.out |egrep "jar"|awk -F'[' '{print $3}'|awk -F']' '{print $1}'|awk -F'lib/' '{print $2}'>a.txt 將裡面的jar包設定跳過檢查處理 vi /usr/local/apache/conf/catalina.properties 檔案中的 “tomcat.util.scan.StandardJarScanFilter.jarsToSkip=” 處,儲存該檔案
2、安裝錯誤資訊02
上面報錯資訊處理後,發現啟動tomcat還是無法訪問xwiki(404錯誤),這裡只能開啟xwiki的debug模式檢視具體報錯資訊
設定debug日誌模式:
cd /usr/local/apache/webapps/xwiki/WEB-INF/classes touch logging.properties ##具體新增內容如下 handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ org.apache.juli.FileHandler.level = FINE org.apache.juli.FileHandler.directory = /usr/local/apache/logs org.apache.juli.FileHandler.prefix = error-debug. java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
重啟tomcat,檢視錯誤日誌內容
錯誤資訊主要如下:
Unsupported major.minor version 52.0
處理方法:
根據錯誤資訊,基本可以確認是由於jdk版本導致的,檢視需要1.8版本的Jdk,下載高版本的jdk安裝後,重啟問題解決
wget "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm"
rpm -ivh jdk-8u161-linux-x64.rpm