tomcat+mysql+xwiki搭建开源wiki系统
xwiki是使用java语言编写的开源wiki系统 xwiki有多种版本,standalone的版本可以直接下载之后独立安装,默认集成了jetty运行,但是这种方式安装xwiki,运行速度比较慢,在大部分的情况下不能满足企业的需求。在linux系统上实现部署xwiki也有多种方式:
其中serlet container就有许多:
tomcat glassfishjboss等
关系型数据库的选择也是比较广泛的,在此使用tomcat和mysql
第一步:下载xwiki的war包
wget http://download.forge.ow2.org/xwiki/xwiki-enterprise-web-6.3.war
第二步:安装jdk 安装jdkde要点主要就是环境变量 导出JAVA_HOME JRE_HOME1. 导出可执行程序到PATH变量
tar -zxvf jdk-8u73-linux-x64.tar.gz
mv jdk1.8.0_73 /usr/local/jdk
echo "JAVA_HOME=/usr/local/jdk" >>/etc/profile echo "CLASSPATH=.:$JAVA_HOME/lib.tools.jar" >>/etc/profile echo "PATH=/usr/local/jdk/bin:/bin:/sbin:/usr/sbin:/bin:/usr/bin:/root/bin" >>/etc/profile echo "export JAVA_HOME CLASSPATH PATH" >>/etc/profile source /etc/profile2.查看jdk的版本
usr/local/jdk/bin/java -version
java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)第三步:安装tomcat(/usr/local/tomcat/)
tar -zxvf apache-tomcat-6.0.32.tar.gz -C /usr/local/ cd /usr/local/ mv apache-tomcat-6.0.32 tomcat1.tomcat的命令 cd tomcat bin/startup.sh 启动服务命令 bin/shutdown.sh 停止服务命令 webapps/ROOT/ 网页目录 conf 配置文件存放目录2.查看端口
netstat -untnalp | grep :8080
cd /usr/local/tomcat/webapps/ mkdir xwiki mv xwiki-enterprise-web-6.3.war /usr/local/tomcat/webapps/xwiki/ unzip xwiki-enterprise-web-6.3.war第四步:安装mysql(数据库存放目录 /usr/local/mysql/data/)
安装配置工具cmake [root@localhost cmake-2.8.10.2]# ./bootstrap --prefix=/usr/local/cmake[root@localhost cmake-2.8.10.2]# make [root@localhost cmake-2.8.10.2]# make install[root@localhost local]# /usr/local/cmake/bin/cmake --version
cmake version 2.8.10.2 使用camke配置安装源码mysqltar -zxvf mysql-5.5.13.tar.gz cd mysql-5.5.13/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/home/mysql -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
make
make install
初始化授权库
cd /usr/local/mysql./scripts/mysql_install_db --user=mysqlls /usr/local/mysql/data/mysql/ -lchmod 777 data
创建mysql数据库的主配置文件
cd mysql-5.5.13/support-files/ cp my-medium.cnf /etc/my.cnf3.启动数据库服务
/usr/local/mysql/bin/mysqld_safe --user=mysql &4.使用数据库管理员从数据库服务器本机登录(没密码)
/usr/local/mysql/bin/mysql -uroot -p5.设置数据库管理员从本机登录的密码
/usr/local/mysql/bin/mysqladmin -hlocalhost -uroot password "123"kill -9 %1
pkill -9 mysqld /usr/local/mysql/bin/mysqld_safe --user=mysql &/usr/local/mysql/bin/mysql -uroot -p123 (不加密码无法登录)
6.把mysql命令所在的路径添加到系统环境变量PATH里
export PATH=/usr/local/mysql/bin:$PATHvim /etc/bashrc
export PATH=/usr/local/mysql/bin:$PATH :wq7.给源码mysql服务编写启动脚本
cd mysql-5.5.13/support-files/ cp mysql.server /etc/init.d/mysqldd chmod +x /etc/init.d/mysqlddchkconfig --add mysqldd
chkconfig --list mysqldd mysqldd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[root@localhost support-files]# netstat -untlap | grep :3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 38572/mysqld [root@localhost support-files]# pkill -9 mysqld[1]+ 已杀死 /usr/local/mysql/bin/mysqld_safe --user=mysql[root@localhost support-files]# netstat -untlap | grep :3306service mysqldd status service mysqldd startservice mysqldd statusservice mysqldd stopservice mysqldd start更改包大小:默认是1M,WiKi导入超过1M的文件会出错。
vi /etc/my.cnf
更改max_allowed_packet = 1M为max_allowed_packet = 32M创建XWiki的数据库:
8.创建xwiki的数据库:
mysql -uroot -p
mysql> create database xwiki mysql> grant all privileges on xwiki.* to xwiki@127.0.0.1 identified by 'xwiki';不要使用MyISAM存储引擎,因为MyISAM不支持事务处理,推荐使用InnoDB存储引擎。
vi /etc/my.cnf
[client]
#password = your_passwordport = 3306socket = /tmp/mysqld.sockdefault-character-set=utf8[mysqld]
port = 3306socket = /tmp/mysqld.sockskip-external-lockingkey_buffer_size = 16Mmax_allowed_packet = 32Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8Mdefault-storage-engine=INNODB第五步:下载wiki和MySQL连接工具
下载MySQL JDBC Driver Jar放到/data/app_platform/xwiki_tomcat/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 mv mysql-connector-java-5.1.34.jar /usr/local/tomcat/webapps/xwiki/WEB-INF/lib/ cd /usr/local/tomcat/webapps/wiki/WEB-INF/lib/ cp -p hibernate.cfg.xml hibernate.cfg.xml-bak vi hibernate.cfg.xml 删除所有多余的配置文件。 [root@fanxh WEB-INF]# cat hibernate.cfg.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration> <session-factory> <!-- MySQL configuration. Uncomment if you want to use MySQL and comment out other database configurations. --> <property name="connection.url">jdbc:mysql://localhost/xwiki</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="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"/></session-factory>
</hibernate-configuration>1.XWIKI字符集编码配置
修改 web.xml文件 /data/app_platform/xwiki_tomcat/webapps/xwiki/WEB-INF/xwiki.cfg#-# The encoding to use when transformin strings to and from byte arrays. This causes the jvm encoding to be ignored,
#-# since we want to be independend of the underlying system.xwiki.encoding=UTF-82.修改hibernate.cfg.xml hibernate.cfg.xml中添加<property name="connection.useUnicode">true</property><property name="connection.characterEncoding">UTF-8</property>3.MySQL的配置文件my.cnf
[client]default-character-set=utf8[mysqld]default-character-set=utf8character-set-server=utf8collation-server=utf8_bin4.管理附件(/var/local/xwiki/)
默认情况下,XWIKI使用数据库存储附件,上传的附件最大为30M左右,同时MySQL的配置文件my.cnf中要设置max_allowed_packet为最大值的3倍左右,因为存储历史版本也会耗费空间
使用文件系统存储可以上传更大的附件,XWIKI使用一个临时目录来存储从数据库中调出的图片或附件。附件的存储目录在xwiki.properties中设定,不可以随意增加或删除这个目录下的内容,因为每个附件在数据库中都有相应的元数据
#-# Note if the system property xwiki.data.dir is set then this property is not used.#-# If neither the system property nor this configuration value here are set then the Servlet container's temporary#-# directory is used; This is absolutely not recommended since that directory could be wiped out at any time and you#-# should specify a value.environment.permanentDirectory=/var/local/xwiki/最好在第一次运行XWIKI的时候就设定好附件的存储方式
在xwik.cfg文件中设置
xwiki.store.p_w_upload.hint=filexwiki.store.p_w_upload.versioning.hint=filexwiki.store.p_w_upload.recyclebin.hint=file用管理员登陆的话,需要修改xwiki.cfg,将xwiki.superadminpassword=system 前面#去掉, 用superadmin/system登陆即可。