Zotonic是一个基于erlang语言开发的开源的具高性能的网站内容管理系统(CMS),zotonic还包括了实时框架(real-time framework),a web server。zotonic具有弹性、可扩展性,并且从一开始就是提供了对动态交互网站以及移动端系决方案的支持。
背景
当学习Erlang的时候我就觉得这是一门奇葩而又神奇的语言,后来在知乎阅读Erlang相关资料时候看到有人说Erlang还有可一应用在网站建设管理方面,并存在诸如高性能的yaws服务器等erlang应用。但是,zotonic与cms相关的字眼一跳入眼帘就吸引了我尝试的兴趣,因为本人很看重网站开发建设方面的 应用场景。通过各种渠道的信息,我了解到,zotonic年轻,新颖,富有很多现代思想,没有之前很多框架的存在多版本支持的历史包袱。
当我初次尝试zotonic时,版本号码为0.13.0,并且安装文档仅提供了Linux下的debian系方案。当时我的开发环境时CentOS6.x/7.x(Redhat系),Erlang采用了默认yum源安装方案,在zotonic所需软件配置齐全后进行的安装屡出问题,最终我只能搁置。两个月前工作闲暇之余,我发Email跟Zotonic支持团队沟通问题是否CentOS系统支持上面,得到CentOS支持没有问题的回复。但是当时对于Zotonic采用的PostgreSQL的配置管理还存在问题,而且又没有大把的时间,只好暂且搁置。
当中秋节来临时准备好再次尝试zotonic时候,发现版本号stable已经到了0.20.0,其中1.x版本也已经出来,而且PostgreSQL的配置管理已有突破。所以就有了本次有关zotonic在安装CentOS下安装过程的文章。
准备
操作系统版本为CentOS7.2,但是不含gcc,g++,PostgreSQL,Erlang等,可以说从0开始。Zotonic对Erlang的要求为:
- Erlang 18 or higher
- PostgreSQL 8.4 or higher
- ImageMagick 6.5 or higher for image resizing
- Git for pulling in external dependencies
1、PostgreSQL安装
a. 采用默认源安装
yum -y install postgresql-server postgresql-contrib
b. 初始化数据库
service postgresql initdb start
c. 启动postgreSQL的server
systemctl start postgresql.service
d. 设置默认启动
systemctl enable postgresql.service
e. 修改数据库用户postgres密码
PostgreSQL数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为’postgres’。
# su - postgres
$ psql
# ALTER USER postgres WITH PASSWORD 'postgres';
# select*from pg_shadow ;
f. 修改默认配置文件
默认配置文件目录为/var/lib/pgsql/data
配置文件pg_hba.conf
将验证方式改为MD5即可在普通系统目录下面登陆postgresql数据库
# "local" is for Unix domain socket connections only
#local all all peer
local all all md5
# IPv4 local connections:
#host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5
# IPv6 local connections:
#host all all ::1/128 ident
host all all ::1/128 md5
完成一上设置步骤算是PostgreSQL初步安装完成,可以进行下一步的准备工作。
2、安装ImageMagick
a. 查看默认源提供的版本
[root@localhost zotonic]# yum list ImageMagick
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Installed Packages
ImageMagick.x86_64 6.7.8.9-15.el7_2 @updates
Available Packages
ImageMagick.i686 6.7.8.9-15.el7_2 updates
版本符合zotonic的要求
b. 安装ImageMagick
yum install ImageMagick
3、Erlang安装
yum search erlang居然没有任何信息,那是内心不知是崩溃还是应该庆幸,因为后面的环境要求时Erlang18的版本,想想垃圾的yum源也不会提供这么高的erlang版本(PS:想想在CentOS7.x时候提供的Erlang16的版本我整个人都觉得不好了)。老老实实从Erlang.org上下载了200MB+的18.3源码,中间下载过程无比慢,但是架不住宝宝铁了心自行安装的决定。
a. 安装gcc
yum install gcc gcc-g++ gcc*
b. 安装加密crypto模块
yum install crypto*
c. 安装odbc数据库驱动
yum install postgresql-odbc
d. 安装fop
[root@localhost zotonic]# yum search fop
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
=========================================================== N/S matched: fop ===========================================================
fop-javadoc.noarch : Javadoc for fop
fop.noarch : XSL-driven print formatter
Name and summary matches only, use "search all" for everything.
[root@localhost zotonic]# yum install fop
e. 配置
未作准备前的配置日志显示
*********************************************************************
********************** APPLICATIONS DISABLED **********************
*********************************************************************
crypto : No usable OpenSSL found
jinterface : Java compiler disabled by user
odbc : ODBC library - link check failed
ssh : No usable OpenSSL found
ssl : No usable OpenSSL found
*********************************************************************
*********************************************************************
********************** APPLICATIONS INFORMATION *******************
*********************************************************************
wx : wxWidgets not found, wx will NOT be usable
*********************************************************************
*********************************************************************
********************** DOCUMENTATION INFORMATION ******************
*********************************************************************
documentation :
fop is missing.
Using fakefop to generate placeholder PDF files.
*********************************************************************
设置准备后显示
*********************************************************************
********************** APPLICATIONS DISABLED **********************
*********************************************************************
jinterface : Java compiler disabled by user
*********************************************************************
*********************************************************************
********************** APPLICATIONS INFORMATION *******************
*********************************************************************
wx : Can not link the wx driver, wx will NOT be useable
*********************************************************************
f. 编译安装Erlang
[root@localhost otp_src_18.3]# make && make install
g. 修改profile
vim打开/etc/profile,在最末一行加入下面配置信息
export PATH=$PATH:/usr/bin/erlang/bin
重启系统,erlang启动就写入配置
h. 检查erlang的crypto模块
[root@localhost rebar]# erl
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.3 (abort with ^G)
1> crypto:start().
ok
4、Rebar编译
a. 下载源码
git clone git://github.com/rebar/rebar.git
b. 编译
root@localhost rebar]# ./bootstrap
c. 移动rebar到安装目录
root@localhost rebar]# mv rebar ~/zotonic/
安装Zotonic
1、编译
[root@localhost zotonic]#make
2、在debug状态启动zotonic
[root@localhost zotonic]# bin/zotonic debug
3、web访问
本地浏览器打开 http://127.0.0.1:8000, 页面如下
4、查找密码
通过页面提示发现密码所在文件路径为
/root/.zotonic/0/zotonic.config
查找发现密码行
%%% Password for the sites administration site (zotonic_status). Will
%%% be generated on first Zotonic startup, if the config file does not yet exist.
{password, "7745f34ff559e7fc2878"}
5、输入密码登陆
页面如下
6、小结
到这一步,zotonic环境算是部署成功,但是有关后台调取PostgreSQL的配置还没有完结。敬请期待
问题
1、Erlang编译错误no curses
checking for kstat_open in -lkstat... (cached) no
checking for tgetent in -ltinfo... no
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltermlib... no
configure: error: No curses library functions found
解决方案时安装ncurses-devel,
[root@localhost ~]# yum install ncurses-devel
2、 rebar编译报错与排错
Recompile: src/rebar_xref
Uncaught error in rebar_core: {'EXIT',
{undef,
[{crypto,start,[],[]},
{rebar,run_aux,2,
[{file,"src/rebar.erl"},{line,163}]},
{rebar,main,1,
[{file,"src/rebar.erl"},{line,58}]},
{erl_eval,do_apply,6,
[{file,"erl_eval.erl"},{line,657}]},
{escript,eval_exprs,5,
[{file,"escript.erl"},{line,865}]},
{erl_eval,local_func,5,
[{file,"erl_eval.erl"},{line,544}]},
{escript,interpret,4,
[{file,"escript.erl"},{line,781}]},
{escript,start,1,
[{file,"escript.erl"},{line,276}]}]}}
这是由于Erlang在编译时候没有加入crypto模块造成的,我采取在编译erlang前安装crypto相关软件解决该问题。
3、Rebar可执行文件
编译rebar不是必须的,但是编译过程可以暴露出来很多rebar运行依赖的问题,即便我们下载了rebar可执行文件,当环境缺少依赖时候,rebar照样无法正常运行。所以建议采用编译方案,目的是为了测试rebar运行环境。
4、wxWidgets问题
erlang编译安装时候时提示需要wxWidgets,编译安装erlang前我也编译安装了wxWidget,从erlang安装结果来看wx好像没有太大影响。另外我没有发现wxWidgets在zotonic起的具体作用,所以就放弃了对问题与解决方案的记录,相信有童鞋遇到编译wxWidgets问题能够从网上找到合适的解决方案。
5、zotonic配置文件zotonic.config
配置文件zotonic.config并不在编译时候zotonic源码所在的路径,而是在编译所用系统用户默认路径下,示例路径为/root/.zotonic/0/zotonic.config,诚如zotonic登陆页面提示信息:
You can find the password in ~/.zotonic/[version]/zotonic.config.
参考
1、Zotonic http://zotonic.com/docs/0.x/index.html
2、Rebar http://cryolite.iteye.com/blog/1159448
3、crypto相关 http://stackoverflow.com/questions/4742184/rebar-error-exit-on-create-app-crypto-start

113

被折叠的 条评论
为什么被折叠?



