在Ubuntu中配置ErlyWeb环境

由于更换使用了Winddows 7操作系统,在以前windows 2003上能正常开发的ErlyWeb在Win 7下面由于没有安装OpenSSL的缘故,而且主要的还是erlang的mysql驱动在windows系统下不能很好的工作,经常连接不上,需要重复执行N(N>3)次命令,很是恼火,由于Erlang大部分都是在Linux使用,所以想着在Linux下开发。

在选择Linux时,考虑到Fedora Linux安装需要很大的硬盘空间,所以暂不考虑,平常上CSDN经常看到老袁在鼓吹Ubuntu系统时多么的好,所以决定采用Ubuntu,安装完成以后,检查到Ubuntu 9.10版本已经默认安装了erlang R13B01的版本,不过都不全,缺少一些lib,在经过用Ubuntu的新立得软件安装工具获取完整的R1301版本后,就已经完整的安装好了,在终端输入erl,显示如下:

 

第二步 安装erlyweb的开发框架,在http://www.erlyweb.org/网站中下载 erlyweb-0.7.1.tar.gz 文件,然后解压到/usr/lib/erlang/lib中,在这里需要执行erlyweb-0.72文件夹内的make.sh文件,目的是需要重新编译一些文件以及mysql的驱动

 

第三步 从新立得软件工具包中下载yaws,下载后将会自动安装,这里我们主要要用到的文件是位于/etc/yaws/下面的yaws.conf文件,它是用来配置erlyweb服务的,稍候即将要介绍到,还有一个地方就是/etc/init.d/yaws,用来停止和开启服务,不过,在开发模式下一般不用这个,因为不能像在控制台中那样输出信息

yaws安装完成后可以在浏览器中输入http://localhost:8080/来验证是否成功启动

 

第四步  就是安装mysql,同样是在新立得软件安装包可以找到.在这里说明下,用Ubuntu的新立得安装工具安装一些软件,可以免去自己需要下载源文件,然后make,而且有时间自己make'的时候缺少一些依赖包.安装完mysql服务器后,还安装了两个辅助软MySQL Administrator和MySQL Query Browser.待MySQL安装完成后,利用erlydb:start(mysql,[{hostname,"localhost"},{username,"root"},{password,"123456"},{database,"blog"}]).测试连接。OK,马上就连接到了MySQL,看来还是Linux好啊^_^.

 

第五步 把在windows 平台下的erlyweb项目拷贝过来,同时对于一些配置文件做修改,比如在windows下的路径要相应的改成linux下的,配置完成后,进入erl shell中,进行编译,这里我拿一个test项目做演示.把test文件夹拷贝到/erl-web/www/目录下,从终端中进入test目录,执行erl shell,编译项目文件test.erl

编译成功后,然后再执行test:start().编译整个项目的.

 

编译成功后,就可以在/etc/yaws/yaws.conf中配置erlyWeb应用程序了.首先在yaws.conf配置文件中找到ebin_dir的地方,新增一个路径ebin_dir = /erly-web/www/test/ebin,然后找到runmod,配置runmod = test,作用的在yaws启动时重新编译test项目,剩下的就是配置服务节点了:

<server localhost>
  port = 8000
  listen = 0.0.0.0
  docroot = "/erly-web/www/test/www"
  appmods = <"/", erlyweb>
  <opaque>
    appname = test
  </opaque>
</server>

注意的是端口号要是配置8080的话,会提示着莪个端口号已经被一个应用占用.yaws配置完成后就可以在终端中输入yaws i来启动服务了.

root@ubuntu:/erly-web/www/test/ebin# yaws -i
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:true]


=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Using config file /etc/yaws/yaws.conf
Eshell V5.7.2  (abort with ^G)
1>
=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Using subconfig file /etc/yaws/conf.d/localhost.conf

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Using subconfig file /etc/yaws/conf.d/localhost-ssl.conf
yaws:Add path "/erly-web/www/test/ebin"
yaws:Add path "/usr/lib/yaws/ebin"
yaws:Add path "/usr/lib/erlang/lib/yaws-1.82/examples/ebin"
yaws:Running with id=default (localinstall=false)
Running with debug checks turned on (slower server)
Logging to directory "/var/log/yaws"

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Ctlfile : /root/.yaws/yaws/default/CTL

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
sync call test:start

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Listening to 0.0.0.0:8443 for servers
 - https://localhost:8443 under /usr/share/yaws

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Listening to 0.0.0.0:8080 for servers
 - http://localhost:8080 under /usr/share/yaws

=INFO REPORT==== 9-Dec-2009::07:19:47 ===
Yaws: Listening to 0.0.0.0:8000 for servers
 - http://localhost:8000 under /erly-web/www/test/www
mysql_conn:620: greeting version "5.0.83-0ubuntu3" (protocol 10) salt "0?-d///aS" caps 41516 serverchar <<8,2,0,0,
                                                                                                          0,0,0,0,
                                                                                                          0,0,0,0,
                                                                                                          0,0,0,0>>salt2 "]X!9=fjc0b!y"
mysql_auth:187: mysql_auth send packet 1: <<5,162,0,0,64,66,15,0,8,0,0,0,0,0,0,
                                            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                                            114,111,111,116,0,20,104,188,163,
                                            206,76,9,23,144,130,238,3,87,7,56,
                                            214,5,110,144,46,50>>
mysql_conn:426: fetch <<"use blog">> (id <0.90.0>)
debug:erlyweb_compile:379: Compiling Erlang file "test_app_controller"
debug:erlyweb_compile:379: Compiling Erlang file "error_controller"
/erly-web/www/test/src/components/error_controller.erl:4: Warning: variable 'A' is unused
debug:erlyweb_compile:379: Compiling Erlang file "show_controller"
debug:erlyweb_compile:374: Compiling ErlTL file "show_view"
debug:erlyweb_compile:374: Compiling ErlTL file "success_view"
debug:erlyweb_compile:374: Compiling ErlTL file "error_view"
debug:erlyweb_compile:379: Compiling Erlang file "posting_controller"
debug:erlyweb_compile:379: Compiling Erlang file "author_view"
debug:erlyweb_compile:379: Compiling Erlang file "success_controller"
/erly-web/www/test/src/components/success_controller.erl:7: Warning: variable 'A' is unused
/erly-web/www/test/src/components/success_controller.erl:13: Warning: variable 'Opts' is unused
/erly-web/www/test/src/components/success_controller.erl:31: Warning: variable 'Opts' is unused
debug:erlyweb_compile:374: Compiling ErlTL file "login_view"
debug:erlyweb_compile:379: Compiling Erlang file "paging_controller"
/erly-web/www/test/src/components/paging_controller.erl:7: Warning: variable 'A' is unused
debug:erlyweb_compile:374: Compiling ErlTL file "html_container_view"
debug:erlyweb_compile:379: Compiling Erlang file "login_controller"
debug:erlyweb_compile:379: Compiling Erlang file "html_container_controller"
debug:erlyweb_compile:379: Compiling Erlang file "home_controller"
debug:erlyweb_compile:374: Compiling ErlTL file "paging_view"
debug:erlyweb_compile:379: Compiling Erlang file "posting"
debug:erlyweb_compile:374: Compiling ErlTL file "home_view"
debug:erlyweb_compile:379: Compiling Erlang file "author_controller"
debug:erlyweb_compile:379: Compiling Erlang file "author"
debug:erlyweb_compile:379: Compiling Erlang file "posting_view"
debug:erlyweb_compile:374: Compiling ErlTL file "test_messages"
debug:erlyweb_compile:379: Compiling Erlang file "test"
debug:erlyweb_compile:114: Generating ErlyDB code for models: "author.erl posting.erl "
mysql_conn:426: fetch <<"show tables">> (id <0.90.0>)
mysql_conn:426: fetch <<"describe author">> (id <0.90.0>)
mysql_conn:426: fetch <<"describe posting">> (id <0.90.0>)
debug:erlydb:355:

--- To skip foreign key checks, compile with the {skip_fk_checks, true} option


debug:erlydb:391: Generating code for posting
debug:erlydb:391: Generating code for author

 

最后就是在浏览器中输入http://localhost:8000/来看看效果吧

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值