MochiWeb是一个用来构建Web应用的轻便,高效的HTTP应用框架的Erlang库。
【1】编译安装Erlang
wget http://erlang.org/download/otp_src_R16B.tar.gz tar zxvf otp_src_R16B.tar.gz
cd otp_src_R16B/
./configure
make
make install
安装配置mochiweb
获取mochiweb在github上的源代码
|
git
clone git://github.com/mochi/mochiweb.git
|
创建一个项目,名字叫first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@centos1
mochiweb]# cd mochiweb/
[root@centos1
mochiweb]# make app PROJECT=first
==>
mochiweb (create)
Writing ../first/src/first.app.src
Writing
../first/src/first.erl
Writing ../first/src/first_app.erl
Writing
../first/src/first_deps.erl
Writing ../first/src/first_sup.erl
Writing
../first/src/first_web.erl
Writing ../first/start-dev.sh
Writing
../first/priv/www/index.html
Writing ../first/.gitignore
Writing
../first/Makefile
Writing ../first/rebar.config
Writing
../first/rebar
|
编译运行first项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
cd
../first
make
./start-dev.sh
会看到有下面这一段,监听的端口,IP,和网页文件的目录
=SUPERVISOR
REPORT====
20-Jun-2013::11:30:49
===
Supervisor:
{local,first_sup}
Context: start_error
Reason:
eaddrinuse
Offender:
[{pid,undefined},
{name,first_web},
{mfargs,{first_web,start,
[[{ip,{0,0,0,0}},
{port,8080},
{docroot,"/opt/first/priv/www"}]]}},
{restart_type,permanent},
{shutdown,5000},
{child_type,worker}]
(first_dev@centos1)1>
|
打一下回车,就进入到了mochiweb的shell模式。
浏览器访问测试一下
http://youip:8080 可以看到项目正在运行,表示安装成功