Java开源Blog实现,Roller 2.0 的安装手记!

Java开源Blog实现,Roller 2.0 的安装手记!

Roller 是一个Struts + Hibernate 的 Java 开源实现,正好拿来研究研究,首先就是要把它安装起来了,整理
了一下步骤和注意事项,记录如下:

准备需要的基本环境:

1. Java 2 SDK 1.4.2_10
2. Tomcat 5.0.28
3. Roller 2.0
4. MySQL 5.0.16

首先,确保MySQL开启了对InnoDB和UTF-8的支持,在my.ini中开启下面的参数:

[mysqld]
default-storage-engine=innodb
default-character-set=utf8


启动好MySQL待用...D:\MySQL\mysqld.exe --console --datadir=I:\MyData\Data

假设我的Tomcat主目录为:$CATALINA_HOME=D:\J2EE_HOME\AppServer\Tomcat

把压缩的Roller文件 roller-2.0-incubating.tar 解开...
并放到
$CATALINA_HOME\WebApp\roller下面...如图...

Java开源Blog实现,Roller 2.0 的安装手记!

开始建立MySQL中的数据库:
 I:> CD %CATALINA_HOME%\webapps\roller\WEB-INF\dbscripts\mysql
I:> mysql -u root -p
password: *****
mysql> create database roller;
mysql> grant all on roller.* to scott@'%' identified by 'tiger';
mysql> grant all on roller.* to scott@'localhost' identified by 'tiger';
mysql> use roller;
mysql> source createdb.sql
mysql> quit


$CATALINA_HOME\conf\Catalina\localhost 中放置Roller的Web Application的部署
配置档案 roller.xml,内容如下:

<Context path="/roller" docBase="${catalina.home}/webapps/roller" debug="0">
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/roller?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8"
connectionName="scott"
connectionPassword="tiger"
userTable="rolleruser"
userNameCol="username"
userCredCol="passphrase"
userRoleTable="userrole"
roleNameCol="rolename" debug="0" />

<Resource name="jdbc/rollerdb" auth="Container" type="javax.sql.DataSource" />
<ResourceParams name="jdbc/rollerdb">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/roller?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8</value>
</parameter>
<parameter>
<name>username</name>
<value>scott</value>
</parameter>
<parameter>
<name>password</name>
<value>tiger</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>3</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
</ResourceParams>

<!--//
To enable email notification of comments: uncomment the resouce below,
set your mailhost, and make sure you have mail.jar and activation.jar
in <tomcat>/common/lib.
//-->

<!--//
<Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
    
        <value>mailhost.example.com</value>
        </parameter>
    </ResourceParams>
//-->

</Context>

完成上面的设定后,接下来,我们修改一下Tomcat中的Connector的设定,使它能够支持UTF-8的编码,
打开 $CATALINA_HOME\conf\server.xml,做如下修改...

<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="80"
    URIEncoding="UTF-8"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    debug="0" connectionTimeout="20000"
    disableUploadTimeout="true" />

到这里,基本上Tomcat相关的设定就完成了,因为Roller Blog可以支持上传附件和全文检索等功能,
所以,我们还有一个设定的动作...

$CATALINA_HOME\WebApp\roller 中新建下面层次的目录:

 $CATALINA_HOME\WebApp\roller
                         |
                         +---data
                               |
                               +---search-index
                               +---uploads

找到 $CATALINA_HOME\webapps\roller\WEB-INF\classes\roller.properties  ,做如下修改:


# The directory in which Roller will upload files
# uploads.dir=${user.home}/roller_data/uploads
uploads.dir=${TOMCAT_HOME}/webapps/roller/data/uploads

# force Roller to recreate the entire search index)
# search.index.dir=${user.home}/roller_data/search-index
search.index.dir=${TOMCAT_HOME}/webapps/roller/data/search-index



好了,大功告成,启动Tomcat,可以运行Roller了!

你可能感兴趣的:(java)