Configurations Setting for ERLANG to work with both linux and windows. Requirements Need :
- YAWS web server(optional)
- MOCHIWEB Web Server(optional - easy to setup)
- ERLANG(otp/erlang 17.0 at the time of writing) -- installation using kerl is recommended(linux)
- rebar(erlang compiler)
- cygwin(unix-like environment for windows)
- Kerl( easy tools to handle otp/erlang installation - mainly for linux )
- ChicagoBoss(0.8.19 at the time of writing)(MVC Erlang framework)
A large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows. A DLL (cygwin1.dll) which provides substantial POSIX API functionality. After install this, you can use linux command on windows by using cygwin bash CLI.
- Download the installer here : https://www.cygwin.com/install.html , choose either 32bit or 64bit depend on your cpu bit.
- Install the installer, and after finish installation, windows should popup which give you permission to choose the library to download. As cygwin not install all the package and DO NOT INSTALL ALL THE PACKAGE(because there is a package that we dont use). For safety, just leave the installer to choose default option to install.
- DONE!
- You can also intall the package directly from the cygwin bash like linux terminal. To enable this follow further step :
- Install
apt-cyg
firstlynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin
- After that you'll be able to install say the package "lynx" including dependencies by running:
apt-cyg install lynx
- or
apt-cyg install make
- Install
- ( Windows )
- Download it from here https://www.erlang.org/downloads or http://erlang.org/download/otp_win64_18.3.exe (Choose based on your pc's specification)
- Install as ussual
- After finish, need to setup environemt
path
forerl
command to work in CLI. - Go to environment variable setup at windows properties
- Go to installation
erlang folder dir
on program files(location used to install erlang/opt), and copy the fullbin
path, mine is :C:\Program Files\erl7.3\bin
at the time of writing - Go to system variables on system properties(you know that), find variable
path
atSystem Variables's
section. - At the variable path, there must be existing others path available there, we need to append it by separating it with
;
- Append those variable with the copied path. Should be :
....;C:\Program Files\erl7.3\bin;
- Go to installation
- Finish install. Now the
erl
orwerl
command should be avalaible inside CLI.
- ( Linux )
- run
sudo apt-get install erlang
- Done!
- run
Before going through this part, you should see the kerl installation. Find on this page. Skip those part if already intalled
- ( Windows )
- coming...
- ( Linux )
- Before we install erlang build, here is a a command to list the available releases
kerl list releases
, output :Getting the available releases from erlang.org... R10B-0 R10B-10 R10B-1a R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8 R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2 R12B-3 R12B-4 R12B-5 R13A R13B01 R13B02-1 R13B02 R13B03 R13B04 R13B R14A R14B01 R14B02 R14B03 R14B04 R14B_erts-5.8.1.1 R14B R15B01 R15B02 R15B02_with_MSVCR100_installer_fix R15B03-1 R15B03 R15B R16A_RELEASE_CANDIDATE R16B01 R16B02 R16B03-1 R16B03 R16B 17.0-rc1 17.0-rc2 17.0 17.1 17.3 17.4 17.5 18.0 18.1 18.2.1 18.2 18.3 Run "./kerl update releases" to update this list from erlang.org
- Then pick which build to install :
kerl build 17.0 17.0 --> kerl build <release> <build_name>
and if success should see the success message.- Sometime we encounter error when trying to build. Some of them :
checking whether the child waiter thread should be enabled... yes on SMP build, but not on non-SMP build
= to solve run :sudo apt-get install libncurses5-dev
configure: error: No curses library functions found
= to solve run :sudo apt-get install libncurses5-dev
- Now install a build to some location :
kerl install r14b02 /home/**/Documents/erlang/17.0
- Check installation have been registered :
kerl list installations
- And last, we need to activate it :
. /home/**/Documents/erlang/17.0/activate
- Before we install erlang build, here is a a command to list the available releases
- References
Mochiweb is a lightweight http web server created to run erlang code as easy as possible. To run our application. First we need to install Mochiweb and create our application using Mochiweb Built-In command for creating new project.
-
( Windows)
- Open
cygwin
bash terminal - In our example, go to main container place for our application. Mine is :
C:/erlang
. - Cloning mochiweb repo from github
git clone git://github.com/mochi/mochiweb.git
- After finish cloning, enter into directory :
cd mochiweb
- (IMPORTANT) Create our application there by using this command :
make app PROJECT=cobaan
make
command in default does not available on cygwin package, to enable this, we need to download themake
package- See CYGWIN installation step above, go to package installation part. After install
apt-cyg
command, we can installmake
package nby typing :apt-cyg install make
. - DONE!
- Then, re-type
make app PROJECT=cobaan
again(skip if already passed and successfull)
- See CYGWIN installation step above, go to package installation part. After install
- Mochiweb will create
cobaan
application outside the folder mochiweb, not the inside.
- Go into newly created application :
cd ..(jump out into parent dir)
and followed bycd cobaan(project name)
- Compile the new application :
make
- And finally run the server by running the shell script:
./start-dev.sh
, after execute, you can see a bunch of report message indicate that the application are running. - And now, you can open the browser and type
localhost:8080
from the url and see the successfull message there. As default, mochiweb will run the server onport 8080
- Open
-
( Linux )
- In our example, go to main container place for our application. Mine is :
/home/metallurgical/Documents/erlang
. - Cloning mochiweb repo from github
git clone git://github.com/mochi/mochiweb.git
- After finish cloning, enter into directory :
cd mochiweb
- (IMPORTANT) Create our application there by using this command :
make app PROJECT=cobaan
- Mochiweb will create cobaan application outside the folder mochiweb, not the inside.
- Go into newly created application :
cd ..(jump out into parent dir)
and followed bycd cobaan(project name)
- Compile the new application :
make
- And finally run the server by running the shell script:
./start-dev.sh
, after execute, you can see a bunch of report message indicate that the application are running. - And now, you can open the browser and type
localhost:8080
from the url and see the successfull message there. As default, mochiweb will run the server onport 8080
- In our example, go to main container place for our application. Mine is :
-
References
- Installation
apt-cyg
: http://superuser.com/a/41139 - Mochiweb repo : https://github.com/mochi/mochiweb
- Installation
- ( Windows)
- Download it from here http://yaws.hyber.org/download/ or http://yaws.hyber.org/download/Yaws-2.0.2-windows-installer.exe (Choose based on your pc's specification)
- Install as ussual
- After finish, need to setup environemt
path
foryams
command to work in CLI.- Ussually the yams's bin path automatically added into path environment variable. If not, copy the bin's path, mine is :
C:\Program Files (x86)\Yaws-2.0.2\bin;
at the time of writing
- Ussually the yams's bin path automatically added into path environment variable. If not, copy the bin's path, mine is :
- Finish, Now you can start the
yams's
server by typing :yams -i
- You should see the message from the CLI that the
yam's server is running on port ****
- Open it from the browser and should see the yams's page with example.
- ( Linux )
- Coming...
Rebar is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases. rebar is a self-contained Erlang script, so it's easy to distribute or even embed directly in a project. Where possible, rebar uses standard Erlang/OTP conventions for project structures, thus minimizing the amount of build configuration work. rebar also provides dependency management, enabling application writers to easily re-use common libraries from a variety of locations (git, hg, etc).
- ( Windows )
- Cloning rebar repo into specified directory. Must be note that, rebar is standalone code, so, you can install it anywhere as later we will add rebar's path into windows environment path variable.
- Open
cygwin
bash : git clone git://github.com/rebar/rebar.git ( i clone this on C: drive ) - After the cloning, rebar folder should be created. cd into that folder :
cd rebar
- And compile the code :
./bootstrap
(should have bootstrap.bat file on rebar folder) - After execute above command, you should able to see the compile message from the terminal and if successfull should see this message :
Congratulations! You now have a self-contained script called "rebar" in your current working directory. Place this script anywhere in your path and you can use rebar to build OTP-compliant apps.
- After finish compile, you can see the
rebar.cmd
file was created. - To enable
rebar
command works on CMD or cygwin bash, we must add the rebar path into windows environment variable path. - Go to system variable on windows, find the
path
variable under system variable section, and append this path, mine is :....;C:\rebar\rebar;
- Choose ok and done.
- After this, rebar command should available on CLI.
- DONE
- ( Linux )
- Rebar installation are availble from the linux source repo. To install just run :
sudo apt-get install rebar
- The path automatically added into bin folder. And you're done.
- After this we can compile the erlang code using command
./rebar compile
orrebar compile
from the working project directory
- Rebar installation are availble from the linux source repo. To install just run :
- References
- https://github.com/rebar -deprecated(move to below link)
- https://github.com/erlang/rebar3
- ( Windows )
- coming...
- ( Linux )
- Open terminal
ctrl + alt + t
- Download script directly from github :
curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl
- And make it executable :
chmod a+x kerl
- And drop it into the PATH to ensure the
kerl
command is global by :- 1st option : copy the
kerl
's executable file from dir that we download it, and cut those file and paste into :/usr/local/bin
- 2nd option by using terminal :
export PATH=$PATH:/path/where/the/file/is/download/name_of_file_we_downloaded
- 1st option : copy the
- Done, this should be make the
kerl
command is available from any path where you located. - Now we can manage/install/activate/deactivate/list the erlang/otp build anytime.
- Open terminal
- References
- kerl : https://github.com/kerl/kerl
- ( Windows ) - not really suitable for programming developement suckkkkkk
- make sure erlang is installed ( refer erlang part )
- make sure rebar is installed ( refer rebar part )
- make sure git is installed
- Download ChicagoBoss here : http://chicagoboss.org/download.htm or https://github.com/ChicagoBoss/ChicagoBoss/archive/v0.8.19.zip
- Extract archive and copy that folder into your root project container
eg:c://erlang/chicagoBoss [later on chicago will create project inside erlang folder, not inside chicago folder
- open
cygwin
[we need this terminal always as window did't support linux command] - cd into chicagoboss folder
- run
./rebar get-deps
to donwload dependencies - run
./rebar compile
to compile the source - Done!
- Create new project :
make app PROJECT=rahm
- Go into created project :
cd ../rahm
- Create new controller, refer this : https://github.com/ChicagoBoss/ChicagoBoss/wiki/Quickstart
- Start the server using
./start-server.bat
- If success, you can browse the project at
http://localhost:8001/
with port 8001 as default. - Have Fun!!
- ( Linux )
- working test chicago framework is with otp/erlang 17.0 and chicagoBoss 0.8.19
- make sure erlang is installed ( refer erlang part )
- make sure rebar is installed ( refer rebar part )
- make sure git is installed
- Download ChicagoBoss here : http://chicagoboss.org/download.htm or https://github.com/ChicagoBoss/ChicagoBoss/archive/v0.8.19.tar.gz
- Extract archive and copy that folder into your root project container
eg:/home/**/Documents/erlang/chicagoBoss [later on chicago will create project inside erlang folder, not inside chicago folder
- open terminal
cd
into chicagoboss folder- run
./rebar get-deps
to donwload dependencies - run
./rebar compile
to compile the source - Done!
- Create new project :
make app PROJECT=rahm
- Go into created project :
cd ../rahm
- Create new controller, refer this : https://github.com/ChicagoBoss/ChicagoBoss/wiki/Quickstart
- Start the server using
./init-dev.sh
- If success, you can browse the project at
http://localhost:8001/
with port 8001 as default. - Have Fun!!
- References
- ChicagoBoss-0.8.19 : http://chicagoboss.org/download.htm
- ChicagoBoss for windows step(not working - try to test ) : https://github.com/ChicagoBoss/ChicagoBoss/wiki/Windows-instructions
- ChicagoBoss for linux step: https://github.com/ChicagoBoss/ChicagoBoss/wiki/Quickstart