Reprinted: http://blog.csdn.net/minyskirt/article/details/5031221
Erlangweb is an open-source HTTP-based application framework. It uses the Erlang language to quickly and concisely build Web applications. However, currently, this framework only supports Linux platforms. Its official site is http://erlang-web.org /.
The following describes how to download and compile the source code from its website, and then build a web application using the framework:
1. Download
Download the latest framework from http://wiki.erlang-web.org/downloading. For the first time, you can find the example frame. The downloaded file is erlangweb-1.4.tar.gz. Decompress the package to the/OTP/path using tar.
Ii. Compilation
Enter the decompressed/opt/erlangweb-1.4 directory and enter the bin/compile. erl command on the terminal to compile:
Root @ Ubuntu:/OTP/erlangweb-1.4 # bin/compile. erl
Recompile: lib/eptic-1.4/src/e_session
Recompile: lib/eptic-1.4/src/e_multipart_yaws
Recompile: lib/eptic-1.4/src/e_multipart_inets
LIB/eptic-1.4/src/e_multipart_inets.erl: 29: Warning: Regexp: Split/2: The Regexp module is deprecated (will be removed in r15a); Use the re module instead
LIB/eptic-1.4/src/e_multipart_inets.erl: 37: Warning: Regexp: first_match/2: The Regexp module is deprecated (will be removed in r15a); Use the re module instead
LIB/eptic-1.4/src/e_multipart_inets.erl: 39: Warning: Regexp: Split/2: The Regexp module is deprecated (will be removed in r15a); Use the re module instead
LIB/eptic-1.4/src/e_multipart_inets.erl: 41: Warning: Regexp: Split/2: The Regexp module is deprecated (will be removed in r15a); Use the re module instead
LIB/eptic-1.4/src/e_multipart_inets.erl: 57: Warning: Regexp: first_match/2: The Regexp module is deprecated (will be removed in r15a); Use the re module instead
Recompile: lib/eptic-1.4/src/e_mod_yaws
Recompile: lib/eptic-1.4/src/e_mod_inets
Recompile: lib/eptic-1.4/src/e_mod_gen
Recompile: lib/eptic-1.4/src/e_mod_ewgi
Recompile: lib/eptic-1.4/src/e_logger_viewer
Recompile: lib/eptic-1.4/src/e_logger
Recompile: lib/eptic-1.4/src/e_lang
Recompile: lib/eptic-1.4/src/e_json
Recompile: lib/eptic-1.4/src/e_hook
Recompile: lib/eptic-1.4/src/e_file
Recompile: lib/eptic-1.4/src/e_error
Recompile: lib/eptic-1.4/src/e_dispatcher
Recompile: lib/eptic-1.4/src/e_dict
Recompile: lib/eptic-1.4/src/e_db_mnesia
Recompile: lib/eptic-1.4/src/e_db_couchdb
Recompile: lib/eptic-1.4/src/e_db
Recompile: lib/eptic-1.4/src/e_conf
Recompile: lib/eptic-1.4/src/e_component
Recompile: lib/eptic-1.4/src/e_cluster
Recompile: lib/eptic-1.4/src/e_cache_ets
Recompile: lib/eptic-1.4/src/e_cache_disk
Recompile: lib/eptic-1.4/src/e_cache
Recompile: lib/eptic_fe-1.0/src/eptic_fe
Recompile: lib/eptic_fe-1.0/src/e_fe_proxy
Recompile: lib/eptic_fe-1.0/src/e_fe_mod_yaws
Recompile: lib/eptic_fe-1.0/src/e_fe_mod_inets
Recompile: lib/eptic_fe-1.0/src/e_fe_mod_gen
Recompile: lib/eptic_fe-1.0/src/e_fe_gc
Recompile: lib/eptic_fe-1.0/src/e_fe_cluster
Recompile: lib/eptic_fe-1.0/src/e_fe_cache
Recompile: lib/wpart-1.4/src/wtype
Recompile: lib/wpart-1.4/src/wtpl
Recompile: lib/wpart-1.4/src/wpartlib
Recompile: lib/wpart-1.4/src/wpart_xs
Recompile: lib/wpart-1.4/src/wpart_valid
Recompile: lib/wpart-1.4/src/wpart_utils
Recompile: lib/wpart-1.4/src/wpart_master
Recompile: lib/wpart-1.4/src/wpart_gen
Recompile: lib/wpart-1.4/src/wpart_db
Recompile: lib/wpart-1.4/src/wpart_cache
Recompile: lib/wpart-1.4/src/wpart_app
Recompile: lib/wpart-1.4/src/wpart
Recompile: lib/wpart-1.4/src/validate_tool
Recompile: lib/wpart-1.4/src/utf8_api
Recompile: lib/wpart-1.4/src/utf8
Recompile: lib/wpart-1.4/src/erlydtl_expander
Recompile: lib/wparts-1.4/src/wtype_upload
Recompile: lib/wparts-1.4/src/wtype_time
Recompile: lib/wparts-1.4/src/wtype_text
Recompile: lib/wparts-1.4/src/wtype_term
Recompile: lib/wparts-1.4/src/wtype_string
Recompile: lib/wparts-1.4/src/wtype_password
Recompile: lib/wparts-1.4/src/wtype_multilist
Recompile: lib/wparts-1.4/src/wtype_integer
Recompile: lib/wparts-1.4/src/wtype_html
Recompile: lib/wparts-1.4/src/wtype_float
Recompile: lib/wparts-1.4/src/wtype_enum
Recompile: Library/wparts-1.4/src/wtype_datetime
Recompile: lib/wparts-1.4/src/wtype_date
Recompile: lib/wparts-1.4/src/wtype_csv
Recompile: lib/wparts-1.4/src/wtype_collection
Recompile: lib/wparts-1.4/src/wtype_bool
Recompile: lib/wparts-1.4/src/wtype_autocomplete
Recompile: lib/wparts-1.4/src/wtype_atom
Recompile: lib/wparts-1.4/src/wpart_upload
Recompile: lib/wparts-1.4/src/wpart_time
Recompile: lib/wparts-1.4/src/wpart_text
Recompile: lib/wparts-1.4/src/wpart_string
Recompile: lib/wparts-1.4/src/wpart_password
Recompile: lib/wparts-1.4/src/wpart_paginate
Recompile: lib/wparts-1.4/src/wpart_multilist
Recompile: lib/wparts-1.4/src/wpart_lookup
Recompile: lib/wparts-1.4/src/wpart_list
Recompile: lib/wparts-1.4/src/wpart_lang
Recompile: lib/wparts-1.4/src/wpart_integer
Recompile: lib/wparts-1.4/src/wpart_input
Recompile: lib/wparts-1.4/src/wpart_include
Recompile: lib/wparts-1.4/src/wpart_form
Recompile: lib/wparts-1.4/src/wpart_float
Recompile: lib/wparts-1.4/src/wpart_enum
Recompile: lib/wparts-1.4/src/wpart_derived
Recompile: lib/wparts-1.4/src/wpart_datetime
Recompile: lib/wparts-1.4/src/wpart_date
Recompile: lib/wparts-1.4/src/wpart_csv
Recompile: lib/wparts-1.4/src/wpart_comment
Recompile: lib/wparts-1.4/src/wpart_collection
Recompile: lib/wparts-1.4/src/wpart_choose
Recompile: lib/wparts-1.4/src/wpart_bool
Recompile: lib/wparts-1.4/src/wpart_autocomplete
Recompile: lib/wparts-1.4/src/wpart_atom
Recompile: lib/ewgi-0.2/src/ewgi_yaws
Recompile: lib/ewgi-0.2/src/ewgi_test
Recompile: lib/ewgi-0.2/src/ewgi_mochiweb
Recompile: lib/ewgi-0.2/src/ewgi_inets
Recompile: lib/ewgi-0.2/src/ewgi_application
Recompile: lib/ewgi-0.2/src/ewgi_api
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_scanner
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_runtime
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_parser
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_filters
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_deps
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_dateformat
Recompile: lib/erlydtl-0.5.3/src/erlydtl/erlydtl_compiler
Recompile: lib/erlydtl-0.5.3/src/erlydtl
Recompile: lib/ewts-1.0/src/ewts_sup
Recompile: lib/ewts-1.0/src/ewts_dbg
Recompile: lib/ewts-1.0/src/ewts_client
Recompile: lib/ewts-1.0/src/ewts_app
Recompile: lib/ewts-1.0/src/ewts
Recompile: lib/ewts-1.0/src/e_mod_ewts
Compilation completed!
After compilation, the compiled files will be displayed in the Ebin directory under the lib directory.
3. Create a web application
Now that the erlangweb framework has been compiled, you can use the bin/start command to create a new Web application. First, create a new Web application folder in the path where you want to create a web application, such as/root/www/new_project. Then, use the following command to create:
Root @ Ubuntu :~ /Www/new_project #/OTP/erlangweb-1.4/bin/start. erl yaws
Element created: config
Element created: docroot
Element created: Log
Element created: Pipes
Element created: templates
Element created: Bin
Element created: Lib
Element created: releases
Element created: releases/0.1.
Element created: templates/Cache
Element created: docroot/Conf
Element created: Bin/heart
Element created: Bin/to_erl
Element created: Bin/run_erl
Element created: Bin/start
Element created: Bin/stop
Element created: Bin/connect
Element created: Bin/start_interactive
Element created: Bin/start_erl
Element created: releases/start_erl.data
Element created: config/dispatch. conf
Element created: config/errors. conf
Element created: templates/404.html
Element created: templates/501.html
Element created: config/Project. conf
Element created: docroot/autocomplete.css
Element created: docroot/indicator.gif
Element created: docroot/jquery. autocomplete. js
Element created: docroot/jquery. js
Element created: templates/welcome.html
Element created: releases/0.1/start. rel
Element created: releases/0.1/start. Script
Element created: releases/0.1/start. boot
Element created: config/yaws. conf
Element created: docroot/CONF/mime. Types
Element created: config/inets. conf
Element created: config/inets_https.conf
Element created: config/ewgi_inets.conf
Element created: config/ewgi_inets_https.conf
Element created: config/errors_description.conf
Element created: releases/0.1/sys. config
Element created: emakefile
Element created: Bin/compile. erl
Element created: Bin/Add. erl
Element created: Bin/generate. erl
Element created: Bin/test. erl
Element created: Bin/e_component.erl
The following yaws parameter indicates that our application runs in the yaws container. After successful creation, it will generate the following folders in the new_project directory:
4. Run the created web application
After a web application is generated by using start, you also need to compile the newly created web application. Compile the web application by using the following command line:
Root @ Ubuntu :~ /Www/new_project # bin/compile. erl
Compilation completed!
After the compilation is successful, you can run the following command:
Root @ Ubuntu :~ /Www/new_project # bin/start
Starting Erlang Web
Erlang web is running. You can enter http: // localhost: 8080/in the browser to check whether the operation is successful. If it is successful, it will be displayed on the page:
Welcome to the Erlang web!