上周五搭建了下XWIKI,搜索很多资料,写得都是早期版本的方法,自己总结了一下最新的版本的,和以前差别不大,只是说明了一些需要注意的地方,希望对大家有帮助。
1、配置nginx
在ngnix.conf里,用include domains/* 或者include domains/xwiki.test.com
upstream配置:(具体的proxy优化配置,这里略)
upstream xwiki.test.com.tomcat {
server 127.0.0.1:8001
}
server
{
listen 80;
server_name xwiki.test.com;
# access_log /export/servers/nginx/logs/xwiki.test.com;
location / {
proxy_pass http://xwiki.test.com.tomcat;
}
}
2、配置tomcat(略)
4、配置XWIKI(tomcat实例)
1、下载最新war包(xwiki-enterprise-web-5.2.zip)
2、上传到tomcat root文件夹下
3、修改配置文件
xwiki.cfg文件,vi /export/data/tomcatRoot/xwiki.hjf.com/WEB-INF/xwiki.cfg
关键点1:打开超级用户
# Enable to allow superadmin. It is disabled by default as this could be a security breach if
# it were set and you forgot about it.
# xwiki.superadminpassword=system
改为:xwiki.superadminpassword=system
就能以 superadmin/system 登录超级用户了
关键点2:打开数据库访问配置文件
(这里是为了生效mysql的配置)
#-# The path to the hibernate configuration file.
# xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml
改为: xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml
4、启用mysql配置,配置修改vi /export/data/tomcatRoot/xwiki.hjf.com/WEB-INF/hibernate.cfg.xml
1.首先一定要注释掉默认的数据库配置(我之前直接配置时没有注销,启动老报map错误。)
<!-- Configuration for the default database.
Comment out this section and uncomment other sections below if you want to use another database.
Note that the database tables will be created automatically if they don't already exist.
<property name="connection.url">jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
-->
2.修改mysql配置为如下:
<!-- MySQL configuration.Uncomment if you want to use MySQL and comment out other database configurations. -->
<property name="connection.url">
jdbc:mysql://<数据库地址>:<数据库端口号,mysql默认为3306>/xwiki</property>
<property name="connection.username">
root</property>
<property name="connection.password">
123456</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="dbcp.ps.maxActive">20</property>
<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
4.上传mysql jdbc驱动的jar包到WEB-INF/lib中,类似:
mysql-connector-java-5.1.5.jar
5.在mysql数据库中新建xwiki数据库
create database xwiki (或用图形界面也可以)
远程登录授权
use xwiki
grant all privileges on xwiki.* to root@% identified by '123456';
或者
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
5、启动Nginx+tomcat实例+mysql,访问http://xwiki.test.com即可,就会出现英文的XWIKI引导界面了,网上很多人都说什么放到webapps啊什么的,也不说原因,其实在部署 tomcat实例时是可以指定访问路径的,用webapps也是可以的,我这里没有用8080和webapps。
6、导入管理包,目的是为了方便管理,下载地址: http://extensions.xwiki.org/xwiki/bin/view/Extension/Administration+Application
7、然后就可以配置中文访问了,使用页面直接修改为zh或在配置文件中修改为zh即可。
到此大功告成。