今天在Centos6.6下安装erlang,过程真是一波三折,总结一下:
下载erlang源代码包,选择版本,这里以erlang R19为例作说明:
wget http://www.erlang.org/download/otp_src_R19.tar.gz tar -zxf otp_src_19.tar.gz(上传次soft后该user有authority uncompress不要加sudo) cd otp_src_19 sudo mkdir -p /usr/local/erlang ./configure --prefix=/usr/local/erlang sudo make &&sudo make install cd /etc/profile中配置系统环境变量 export ERLANG_HOME=/usr/local/erlang export PATH=$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$ERLANG_HOME/bin:$RABBITMQ_HOME/sbin:$PATH 依赖组件 报错信息 解决 C compiler configure: error: no acceptable C compiler found in $PATH See 'config.log' for more details. yum install gcc curses library configure: error: No curses library functions found configure: error: /bin/sh '/home/otp_src_R16B03/erts/configure' failed for erts yum install ncurses-devel
安装erlang的时候可能会出现以下警告信息,但不影响erlang使用,如果要用到以下apps,就必须装好依赖:
********************************************************************* ********************** APPLICATIONS DISABLED ********************** ********************************************************************* crypto : No usable OpenSSL found jinterface : No Java compiler found odbc : ODBC library - link check failed orber : No C++ compiler found ssh : No usable OpenSSL found ssl : No usable OpenSSL found *********************************************************************
没装依赖的话会遇到什么问题,比如像用crypto,将会提示没有这个函数
Eshell V5.10.4 (abort with ^G) 1> crypto:start(). ** exception error: undefined function crypto:start/0
这里有个问题,如果是装openssl,不是openssl-devel的话,crypto还是无法使用。 依赖组件 没装无法使用的apps 解决 OpenSSL crypto、ssh、ssl yum install openssl-devel Java compiler jinterface yum install java-devel ODBC library odbc yum install unixODBC-devel C++ compiler orber yum install gcc-c++ 事实上,openssl-devel在erlang中还是不能满足使用的,还需要做一些改动。
Eshell V5.10.4 (abort with ^G) 1> crypto:start(). =ERROR REPORT==== 24-Sep-2014::15:10:46 === Unable to load crypto library. Failed with error: "load_failed, Failed to load NIF library: '/home/erl/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m'" OpenSSL might not be installed on this system.
erlang R16B以上版本运行crypto:start()时,提示crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m,是因为新版的libssl库去除了对一些过时算法的支持,如果程序用不到,可以注释掉otp_src_R16B0x/lib/crypto/c_src/crypto.c第81行# define HAVE_EC即可。
Eshell V5.10.4 (abort with ^G) 1> crypto:start(). ok 2> crypto:md5("ggg"). 3> crypto:info_lib(). [{,268439647, }]
网上还有另一种做法:修改openssl对EC的支持
wget http://www.openssl.org/source/openssl-1.0.1i.tar.gz tar -zxf openssl-1.0.1i.tar.gz cd openssl-1.0.1i ./config --prefix=/home/ssl sed -i "s|CFLAG= |CFLAG= -fPIC |" Makefile make && make install
编译erlang的时候要做改动:
./configure --with-ssl=/home/ssl/ --prefix=/home/erl
这里主要注意 APPLICATIONS DISABLED 部分的提示,其他两部分是不影响编译的。
jinterface : No Java compiler found 什么?没有java编译器?其实这里我们可以选择用gcc等其他方式来编译erlang。
如果你安装了gcc,这里就用不上java编译了,因此可以在configure时增加 –disable-javac 避免第二个错误; odbc : ODBC library – link check failed 表示你未安装unixODBC库
好吧,想办法安装下unixODBC:
下载unixODBC源码包(http://www.unixodbc.org/unixODBC-2.2.1.tar.gz)放到某处比如/usr/local下,然后运行下述命令:
tar zxvf unixODBC-2.2.1.tar.gz
cd unixODBC-2.2.1
./configure --prefix=/usr/local/unixODBC-2.2.1 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc --enable-gui=no
make
make install
好吧,有点跑题了,到此unixODBC安装完毕了。
之后回过头cd到之前的otp_src_R13B04目录
执行
./configure --prefix=/home/erlang --without-javac
make
make install
OK,不出意外安装成功了.
给erl做一个软连接到/usr/local/bin/,以方便使用
ln -s /home/erlang/bin/erl /usr/local/bin/erl
测试下
erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G)
1>OK,二郎神可以使用了。