Xwiki安装部署详解

一、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
安装: mvapache-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安装部署详解Xwiki安装部署详解Xwiki安装部署详解Xwiki安装部署详解Xwiki安装部署详解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