opencms 安装细节探讨

简介:

引入:

因为项目需求,我们要用到openCMS。虽然以前用过很多类似的内容管理系统类似Vignette,Fatwire,但是openCMS虽然大体功能差不多,具体并没用过,所以这里做了一些研究,会陆续把这些研究心得分享出来。这里先从openCMS安装讲起,虽然简单,但也有一些值得探讨的问题。


安装亮点1:不可以重复配置openCMS。

我们知道,第一次运行openCMS需要做配置,配置的请求URL是:http://localhost:8080/opencms/setup/ ,但是运行第一次之后就不可以运行第二次了,理由是在安装过程中,它会去调用CmsSetupBean类的prepareSetup10()方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
      * Prepares step 10 of the setup wizard.<p>
      */
    publicvoidprepareStep10() {
  
         if  (isInitialized()) {
             // lock the wizard for further use 
             lockWizard();
             // save Properties to file "opencms.properties" 
             saveProperties(getProperties(),CmsSystemInfo.FILE_PROPERTIES,  false );
  
             setSchemaGeneration( false );
             m_peristenceConfigurator.save();
         }
     }

而这个方法会去调用lockWizard()方法后保存opencms.properties让其生效,lockWizard方法的实现就是把opencms.properties中key为wizard.enabled设为false:

1
2
3
4
publicvoidlockWizard() {
  
         setExtProperty( "wizard.enabled" , CmsStringUtil.FALSE);
}

这会导致我们的opencms.properties被更改:

1
2
3
4
5
6
7
#
# Enable/Disable OpenCms Setup Wizard
# The wizard sets the flag to false after the setup.
# To use the wizard again, reset it manually to true.
# By setting no value, wizard can always be used.
#################################################################################
wizard.enabled=false

而下次运行时候,它会去判断此属性,判断点在CmsAutoSetup类的main()方法中调用的run()方法的第一行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
      * Performs the setup.<p>
      * @throws Exception 
      */
    publicvoidrun() throwsException {
  
         if  (m_bean.getWizardEnabled()) {
  
             longtimeStarted = System.currentTimeMillis();
  
             CmsSetupTests setupTests =  new  CmsSetupTests();
           
         }
}



安装亮点2: 正确设置max_allowed_packet这个mysql系统变量的大小。

在opencms安装过程中,它会对一些DB变量做检查,其代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
      * Returns an optional warning message ifneeded, <code>null</code> if not.<p>
     
      * @param db the selected database key
     
      * @return html warning, or <code>null</code> if no warning
      */
    publicString checkVariables(String db) {
  
         StringBuffer html =  new  StringBuffer( 512 );
         if  (m_con ==  null ){
             return  null // prior error,trying to get a connection
         }
         Exception exception =  null ;
         if  (db.equals( "mysql" )){
             String statement =  "SELECT @@max_allowed_packet;" ;
             Statement stmt =  null ;
             ResultSet rs =  null ;
             longmaxAllowedPacket =  0 ;
             try  {
                 stmt = m_con.createStatement();
                 rs = stmt.executeQuery(statement);
                 if  (rs.next()) {
                     maxAllowedPacket = rs.getLong( 1 );
                 }
             catch  (Exception e) {
                 exception = e;
             finally  {
                 if  (stmt !=  null ){
                     try  {
                         stmt.close();
                     catch  (SQLException e) {
                         // ignore
                     }
                 }
             }
             if  (exception ==  null ){
                 intmegabyte =  1024  1024 ;
                 if  (maxAllowedPacket >  0 ) {
                     html.append( "<p>MySQL system variable <code>'max_allowed_packet'</code>is set to " );
                     html.append(maxAllowedPacket);
                     html.append( " Byte (" );
                     html.append((maxAllowedPacket / megabyte) +  "MB).</p>\n" );
                 }
                 html.append( "<p>Please note that it will not be possible for OpenCms tohandle files bigger than this value in the VFS.</p>\n" );
                 intrequiredMaxAllowdPacket =  16 ;
                 if  (maxAllowedPacket < (requiredMaxAllowdPacket * megabyte)){
                     m_errors.add( "<p><b>Your <code>'max_allowed_packet'</code>variable is set to less than "
                         + (requiredMaxAllowdPacket* megabyte)
                         " Byte("
                         + requiredMaxAllowdPacket
                         "MB).</b></p>\n"
                         "<p>The required value for running OpenCms isat least "
                         + requiredMaxAllowdPacket
                         "MB."
                         "Please change your MySQL configuration (in the<code>my.ini</code> or <code>my.cnf</code>file).</p>\n" );
                 }
             else  {
                 html.append( "<p><i>OpenCms was not able to detect the value of your<code>'max_allowed_packet'</code>variable.</i></p>\n" );
                 html.append( "<p>Please note that it will not be possible for OpenCms tohandle files bigger than this value.</p>\n" );
                 html.append( "<p><b>The recommended value for running OpenCms is 16MB,please set it in your MySQL configuration (in your<code>my.ini</code> or <code>my.cnf</code>file).</b></p>\n" );
                 html.append(CmsException.getStackTraceAsString(exception));
             }
         }
         if  (html.length() ==  0 ) {
             return  null ;
         }
         return  html.toString();
     }

从这里可以看出,对于数据库是mysql的情形,它会先去执行数据库查询读取max_allowed_packet的值,这个变量主要让mysql限制服务器接受的单个数据包的大小(因为在openCMS中,经常要存富文本内容,所以这个值还是要设置大点为好),并且如果它<16MB, 则报错our max_allowed_packet variable is set to less than 16MB。而默认的mysql这个值配置是4MB,所以第一次setup出错。我们在my.ini中将其改为30MB,这样才过了这关:

wKiom1R6f1XxxiwOAAEsVJYPJ_0634.jpg



安装亮点3:opencms中资产的存储。

opencms中,这些资产都是以BLOB形式存储的:

wKioL1R6f4GSuLD4AAK72Iz3D_c513.jpg





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1584636,如需转载请自行联系原作者
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
目录
相关文章
|
虚拟化
VMware Tools 失效处理
VMware Tools 失效处理
433 0
|
11月前
|
安全 前端开发 网络安全
2025年最受欢迎的CMS系统。
在2025年,国内知名CMS系统PageAdmin CMS、国外博客程序Wordpress、PHP论坛系统discuz和电子商务商城系统PrestaShop将为用户提供强大、灵活、易用的CMS管理系统。
677 63
|
监控 关系型数据库 MySQL
MySQL 8.0如何进行索引优化?
【6月更文挑战第14天】MySQL 8.0如何进行索引优化?
364 5
|
11月前
|
存储 分布式计算 Hadoop
MPP 架构与 Hadoop 架构技术选型指南
MPP架构与Hadoop架构是处理海量数据的两大选择。MPP通过大规模并行处理实现快速查询响应,适用于企业级数据仓库和OLAP应用;Hadoop则以分布式存储和计算为核心,擅长处理非结构化数据和大数据分析。两者各有优劣,MPP适合结构化数据和高性能需求场景,而Hadoop在扩展性和容错性上表现更佳。选择时需综合考虑业务需求、预算和技术能力。
1252 14
|
JSON Java Maven
在 Java 中如何将 ArrayNode 转换为 ArrayList
【8月更文挑战第23天】
654 2
|
Java Maven
Java系列之:GroupId和ArtifactId的作用
这篇文章解释了在Maven项目中`GroupId`和`ArtifactId`的含义和作用,其中`GroupId`通常由域和自定义域名组成,用于区分组织或公司,而`ArtifactId`是项目或模块的名称,两者结合用于唯一标识项目包,确保不会与他人的项目包重复。
|
安全 Linux 算法框架/工具
open Euler安全加固
open Euler安全加固
1033 11
|
存储 Java API
Java中的CQRS和事件溯源模式解析
Java中的CQRS和事件溯源模式解析
|
druid Java
Error attempting to get column ‘createTime‘ from result set的异常
Error attempting to get column ‘createTime‘ from result set的异常
781 0
|
Ubuntu Cloud Native Unix
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker 错误
在使用WSL(Ubuntu 18.04.6)时,初学者遇到运行Docker时的错误:“Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”。解决问题的过程包括:首先尝试通过`sudo apt-get install daemon`安装daemon,然后使用`sudo service docker start`启动Docker。通过`sudo service docker status`确认Docker已启动,并成功运行`docker