公司內部中搭建wiki服務做項目管理系統

tomcat+mysql+xwiki搭建開源wiki系統

xwiki是使用java語言編寫的開源wiki系統

   xwiki有多種版本,standalone的版本可以直接下載之後獨立安裝,默認集成了jetty運行,但是這種方式安裝xwiki,運行速度比較慢,在大部分的情況下不能滿足企業的需求。

在linux系統上實現部署xwiki也有多種方式:

    其中serlet container就有許多:
    tomcat
    glassfish 

    jboss等

    關係型數據庫的選擇也是比較廣泛的,在此使用tomcat和mysql

第一步:下載xwiki的war包

    wget http://download.forge.ow2.org/xwiki/xwiki-enterprise-web-6.3.war

第二步:安裝jdk
    安裝jdkde要點主要就是環境變量
    導出JAVA_HOME
    JRE_HOME

1. 導出可執行程序到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/profile

2.查看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     tomcat
1.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配置安裝源碼mysql
tar -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

  1. 初始化授權庫
    cd /usr/local/mysql
    ./scripts/mysql_install_db --user=mysql
    ls /usr/local/mysql/data/mysql/ -l

  2. chmod 777 data

    創建mysql數據庫的主配置文件
    cd   mysql-5.5.13/support-files/
    cp  my-medium.cnf   /etc/my.cnf

3.啓動數據庫服務
    /usr/local/mysql/bin/mysqld_safe   --user=mysql     &

4.使用數據庫管理員從數據庫服務器本機登錄(沒密碼)
    /usr/local/mysql/bin/mysql    -uroot    -p

5.設置數據庫管理員從本機登錄的密碼
    /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:$PATH

    vim /etc/bashrc
    export  PATH=/usr/local/mysql/bin:$PATH
    :wq

7.給源碼mysql服務編寫啓動腳本
    cd    mysql-5.5.13/support-files/
    cp   mysql.server    /etc/init.d/mysqldd
    chmod   +x    /etc/init.d/mysqldd

    chkconfig --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 :3306
service  mysqldd status
 service  mysqldd start
service  mysqldd status
service  mysqldd stop
service  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 [email protected] identified by 'xwiki';

    不要使用MyISAM存儲引擎,因爲MyISAM不支持事務處理,推薦使用InnoDB存儲引擎。

    vi /etc/my.cnf

[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysqld.sock
default-character-set=utf8


[mysqld]
port            = 3306
socket          = /tmp/mysqld.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 32M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
default-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-8
2.修改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=utf8
character-set-server=utf8
collation-server=utf8_bin

4.管理附件(/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.attachment.hint=file
xwiki.store.attachment.versioning.hint=file
xwiki.store.attachment.recyclebin.hint=file

用管理員登陸的話,需要修改xwiki.cfg,將xwiki.superadminpassword=system 前面#去掉,            用superadmin/system登陸即可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章