`
king_tt
  • 浏览: 2107984 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Apache Roller安装与配置

 
阅读更多

Apache Roller简介


0.简介
本文主要介绍了Apache Roller这一Web Blogger的下载、安装、设置以及使用。

1.下载
在Apache的官方网站下载Roller。可以下载Roller的source来进行build或者直接获取binary。
可以在http://roller.apache.org/download.cgi#roller40 获取最新的Roller二进制发布包,源代码以及相关的帮助文档。
如果要获取Roller的整个源代码结构,可以通过svn来获取:
可以使用svn客户端获取最新的roller源代码:
svn co https://svn.apache.org/repos/asf/roller/trunk roller
已经发布的版本代码标记为:
* roller/tag/roller_4.0.1 - final Roller 4.0 release
* roller/tag/roller_4.0 - final Roller 4.0 release
* ...
笔者使用的版本是4.0.1GA(General Available)版本。
笔者将整个的源代码checkout到NetBeans的workspace中以便查看一些模块的设计思想。例如发送邮件通知模块等等。
如果从source进行build,那么需要预先安装J2SE5.0以及Apache Ant。
{
从source构建roller和很简单,只是运行ant脚本即可。
source的结构如下:
apps/weblogger - Roller Weblogger source code
apps/planet - Roller Planet source code
components/core - Roller "Core" or shared code
tools - Dependencies
Roller4.0.1使用ant作为build工具,可以通过运行:
ant build - build roller
ant tests - unit test
运行ant build之后,二进制的程序位于$/roller_4.0.1/apps/weblogger/dist目录下。
}

2.快速安装
无论是从source进行build,还是直接下载二进制的发布包,内容都是一样的。
安装的过程如下:
a.安装MySQL(可以从MySQL官方网站下载Free的社区版)
笔者使用的MySQL是5.0版本。
同时需要下载connector-j的JDBC驱动程序。
b.创建初始的数据库和用户
打开命令行提示符,运行如下的命令:
>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> create database rollerdb;
Query OK, 1 row affected (0.06 sec)

mysql> grant all on rollerdb.* to scott@'%' identified by 'tiger';
Query OK, 0 rows affected (0.13 sec)

mysql> grant all on rollerdb.* to scott@localhost identified by 'tiger';
Query OK, 0 rows affected (0.00 sec)
c.创建roller-custom.properties
在 类路径上创建roller-custom.properties文件(例如如果使用Tomcat作为server,那么将roller- custom.properties文件放在common/classes目录下(tomcat5)或者lib目录下(tomcat6)),文件的内容如 下:
installation.type=auto
database.configurationType=jdbc
database.jdbc.driverClass=com.mysql.jdbc.Driver
database.jdbc.connectionURL=jdbc:mysql://localhost:3306/rollerdb
database.jdbc.username=scott
database.jdbc.password=tiger
mail.configurationType=properties
mail.hostName=smtp-server.example.com
mail.username=scott
mail.password=tiger
该文件定义了数据库以及mail的相关配置信息。
d.检查Servlet容器的JDBC和JavaMail的设置情况
确保JDBC驱动程序包含在类路径上,如果Servlet容器为Tomcat,那么将下载的MySQL的驱动程序以及JavaMail和Activation的jar文件部署在common/lib(tomcat5)或者lib(tomcat6)目录下。
e.部署Roller
使用Servlet容器的管理控制台将Roller发布。Rollor的WAR目录为roller安装目录的webapp/roller。
也可以将webapp/roller目录拷贝到Tomcat的webapps目录下。
f.运行Roller
打开浏览器,在地址栏内输入http://localhost:8080/roller 。Tomcat的默认监听端口为8080,笔者的8080端口已经被占用,所以使用http://localhost:8090/roller 代替。
启动服务器的时候,可以看到Roller Weblogger的读取custom properties文件的消息。
此时如果配置正确,应该可以运行Roller应用。
在初始运行Roller的时候,会检测数据库是否已经初始化完毕,如果是第一次运行,那么会提示用户数据库表结构等没有创建,用户可以创建数据库表结构,创建成功后,会打印日志消息。
一旦数据库创建成功,那么就可以进行用户创建、新建blog以及设置frontpage。
3.Roller安装注意事项
Roller是一个数据库驱动的Java web应用程序,为了运行Roller,需要Java,Java Servlet容器和一个数据库。
从Roller4.0开始,对Java SDK的要求为5.0
可以使用Java应用服务器或者servlet容器就可以运行Roller,servlet容器必须支持Servlet2.4 API 。Roller社区推荐的服务器为Tomcat5.5,6.0,Sun Web Servlet 7.0以及Glassfish 2.0。
可 以使用MySQL或者Apache Derby作为关系数据库。Roller社区推荐使用这两种数据库,但是对于其他的数据库,Roller也包含了创建数据库的脚本,例如 DB2,Derby,HSQL-DB,MS SQL Server,MySQL,Oracle和PostgreSQL。
针对Tomcat,需要下载java mail和activation的相关jar文件放在类路径上面,因为tomcat不包含它们。另外,需要修改tomcat的$home/conf/server.xml文件,添加Unicode支持:
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" debug="0"
acceptCount="100" connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="UTF-8" />
并确保对于每个connector,都进行了上述的设置,例如AJP或者HTTPS。

对于MySQL数据库,如果MySQL的版本为4.1.x,那么使用J/Connector 3.0.x JDBC驱动,而不是3.1.X。如果版本是5.x,那么使用J/Connector 3.1.x JDBC驱动。确保MySQL支持UTF-8字符集。
对于Oracle数据库,使用10g版本的驱动程序,即ojdbc14.jar,即使数据库服务器是Oracle 9.

4.关于roller配置文件
可以只通过roller-custom.properties文件来配置 Roller。该文件是一个java属性文件,用于覆盖Roller内部的roller.properties文件。也就是说,在 roller.properties文件的中可以设置的内容,都可以通过在roller-custom.properties设置进行覆盖。 roller.properties内容如下:
# 手动还是自动创建数据库
installation.type=manual

# 指定数据库的连接方式是jndi还是jdbc
database.configurationType=jndi

# 如果设置为jndi,那么使用如下的jndi名称
database.jndi.name=jdbc/rollerdb

# 对于jdbc,必须覆盖如下的jdbc配置
database.jdbc.driverClass=
database.jdbc.connectionURL=
database.jdbc.username=
database.jdbc.password=

# 指定邮件配置类型是jndi还是属性文件=or 'properties'
mail.configurationType=jndi

# 如果是jndi,那么使用下面的jndi名称
mail.jndi.name=mail/Session

# 如果是属性文件配置,必须设置主机名
mail.hostname=

# 必须覆盖用户名和密码
#mail.username=
#mail.password=

# 上传文件的位置
uploads.dir=${user.home}/roller_data/uploads

# 可用资源文件路径
uploads.url=/resources

# 创建检索索引的目录
search.index.dir=${user.home}/roller_data/search-index

# 主题包存储目录
themes.dir=${webapp.context}

# 启用/禁用组博客
groupblogging.enabled=true

# 启用/禁用博客索引以及检索servlet
search.enabled=true

# 在检索中是否包含评论
search.index.comments=true

# 评论和跟踪
comment.notification.hideCommenterAddresses=false

# 评论设置,最大评论数,最大间隔等
comment.throttle.enabled=false
comment.throttle.threshold=25
comment.throttle.interval=60
comment.throttle.maxentries=250

# 可插拔评论授权
comment.authenticator.classname=/
org.apache.roller.weblogger.ui.rendering.plugins.comments.MathCommentAuthenticator

# 可插拔评论验证
comment.validator.classnames=/
org.apache.roller.weblogger.ui.rendering.plugins.comments.BlacklistCommentValidator,/
org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessLinksCommentValidator,/
org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
#org.apache.roller.weblogger.ui.rendering.plugins.comments.AkismetCommentValidator

comment.validator.excessLinks.threshold=3
comment.validator.excessSize.threshold=1000
#comment.validator.akismet.key=<get one at wordpress.com>

# pluggable comment formatters
comment.formatter.classnames=/
org.apache.roller.weblogger.business.plugins.comment.LinkMarkupPlugin,/
org.apache.roller.weblogger.business.plugins.comment.AutoformatPlugin,/
org.apache.roller.weblogger.business.plugins.comment.HTMLSubsetPlugin

# 启用评论和跟踪黑名单
site.blacklist.enable.comments=true
site.blacklist.enable.trackbacks=true

.......
在该文件中,包含了非常多的自定义以及可插拔的设置,都可以通过在roller-custom.properties文件中进行覆盖。

5.使用Roller
启动服务器并进入Roller后,如果数据库的配置错误导致无法访问数据库,会在页面中给出错误提示信息。如果一切正常的话,会提示创建数据库表(首次运行,并且installation.type=auto)或者进入Roller系统。
如 果Roller启动后,没有发现front-page weblog,那么将会显示提示用户完成安装过程的画面,宝货注册用户,创建weblog以及设置网站的front page。如果只是个人使用的博客系统,那么可以设置个人的博客作为网站的首页。如果是用来运行一个社区,包含多个用户的博客,那么可能需要显示一个集成 的front-page来组合站点的所有博客。此时,创建一个博客来作为front-page,并确保在Server Admin页面设置了aggregated front-page选项。
安装完成之后,要在roller-custom.properties文 件中将installation.type=auto修改为installation.type=manual。需要重启服务器来使修改生效。(为了避免 忘记修改而重新初始化数据库,建议直接运行roller的数据库创建脚本,而不是在开始的时候将其设置为auto,数据库脚本位 于$tomcat.home/webapps/roller/WEB-INF//classes/dbscripts目录下,该目录下包含了几种类型的数 据库创建脚本)

6.小结
本文简要介绍了Roller的安装和使用,Roller作为weblog工具,安装和使用非常简便。更多的设置以及功能,可以通过配置属性文件来完成。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics