Total Pageviews

Tuesday 26 July 2016

安装haskell(ghc)环境

wget https://haskell.org/platform/download/8.0.1/haskell-platform-8.0.1-unknown-posix--full-x86_64.tar.gz
(如果你的系统是32位,则下载https://haskell.org/platform/download/8.0.1/haskell-platform-8.0.1-unknown-posix--full-i386.tar.gz,  https://downloads.haskell.org/~platform/ )
https://downloads.haskell.org/~platform/8.4.3/haskell-platform-8.4.3-unknown-posix--full-x86_64.tar.gz

tar zxvf haskell-platform-8.0.1-unknown-posix--full-x86_64.tar.gz
(解压后,得到hp-usr-local.tar.gz和一个sh文件。删除install-haskell-platform.sh文件.千万不要运行
install-haskell-platform.sh文件,运行它导致我的vps都当机了)
tar zxvf hp-usr-local.tar.gz
(解压出来的目录为usr目录)
mv usr/local/haskell/ /usr/local/
(这样/usr/local/目录下就会出现haskell目录)
cd /usr/local/haskell/
[root@brite haskell]# ls
ghc-8.0.1-x86_64
[root@brite haskell]# cd ghc-8.0.1-x86_64
[root@brite ghc-8.0.1-x86_64]# ls
bin  doc  etc  haskell-platform.cabal  lib  share  version-8.0.1
[root@brite ghc-8.0.1-x86_64]# cd bin
[root@brite bin]# ls
activate-hs  alex  cabal  ghc  ghc-8.0.1  ghci  ghci-8.0.1  ghc-pkg  ghc-pkg-8.0.1  haddock  haddock-ghc-8.0.1  happy  hp2ps  hpc  hsc2hs  HsColour  runghc  runghc-8.0.1  runhaskell  stack
[root@brite bin]# pwd
/usr/local/haskell/ghc-8.0.1-x86_64/bin
[root@brite bin]# ./activate-hs
Couldn't deduce location of ghc root.
...
[root@brite bin]# export GHC_ROOT=/usr/local/haskell/ghc-8.0.1-x86_64/
[root@brite bin]# echo 'export GHC_ROOT=/usr/local/haskell/ghc-8.0.1-x86_64/' >> /etc/profile &&
source /etc/profile
[root@brite bin]# ./ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
[root@brite bin]# ./ghc-8.0.1 --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
[root@brite bin]# echo 'export PATH=$PATH:/usr/local/haskell/ghc-8.0.1-x86_64/bin' >> /etc/profile && source /etc/profile

这样,haskell(ghc)环境就搭建好了。看到/usr/local/haskell/ghc-8.0.1-x86_64/bin/里面的cabal文件了吗?cabal也可以运行了。(cabal install xyz)
项目地址:https://www.haskell.org/platform/linux.html#linux-generic

ghc的以前的版本:https://www.haskell.org/platform/prior.html,有的基于haskell的建站程序需要用到ghc的以前的版本!
https://www.haskell.org/ghc/download,旧的ghc版本的下载

 如果你先安本文安装了ghc和stack,后按http://briteming.blogspot.com/2016/07/hakyll.html的蓝色字部分,运行curl -sSL https://get.haskellstack.org/ | sh ,  会提示说:stack已安装。此时可这样做:

apt-get install -y libgmp-dev
(参考http://i-pogo.blogspot.com/2010/01/usrbinld-cannot-find-lxxx.html)
root@AR:~# stack upgrade --install-ghc
Fetching package index ...remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
Fetched package index.   
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-7.10.3.                                    
Installing GHC ...  


最后显示:
Copying from /tmp/stack-upgrade21366/stack-1.2.0/.stack-work/install/i386-linux/lts-6.0/7.10.3/bin/stack to /root/.local/bin/stack

这个/root/.local/bin/stack的版本比/usr/local/haskell/ghc-8.0.1-i386/bin/stack的版本高一些:
root@AR:~# /root/.local/bin/stack --version
Version 1.2.0 i386 hpack-0.14.0
root@AR:~#
root@AR:~# stack --version
Version 1.1.2, Git revision cebe10e845fed4420b6224d97dcabf20477bbd4b (3646 commits) i386 hpack-0.14.0
root@AR:~# /usr/local/haskell/ghc-8.0.1-i386/bin/stack --version
Version 1.1.2, Git revision cebe10e845fed4420b6224d97dcabf20477bbd4b (3646 commits) i386 hpack-0.14.0
root@AR:~#

--------------

root@brite ~]# cabal install xyz
Config file path source is default config file.
Config file /root/.cabal/config not found.
Writing default configuration to /root/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
You may need to run 'cabal update' to get the latest list of available
packages.
[root@brite ~]# cabal update
Downloading the latest package list from hackage.haskell.org
[root@brite ~]# cabal install hakyll (此步骤耗时1小时50分钟)
[root@brite ~]# cabal install yst (此步骤耗时40分钟)
(中途会遇到“错误”提示:
Configuring HDBC-sqlite3-2.3.0.0...
setup: Missing dependency on a foreign library:
* Missing C library: sqlite3
解决办法:apt-get install sqlite3 libsqlite3-dev -y
参考:http://stackoverflow.com/questions/2795737/installation-hdbc-sqlite3-haskell)
再次运行cabal install yst即可成功安装yst.
root@AR:~# which yst
root@AR:~# find / -name yst
/root/.cabal/packages/hackage.haskell.org/yst
/root/.cabal/bin/yst
^C
root@AR:~# echo 'export PATH=$PATH:/root/.cabal/bin/' >> /etc/profile
root@AR:~# . /etc/profile
root@AR:~#

项目地址:https://github.com/jgm/yst
----------
相关帖子:https://briteming.blogspot.com/2016/12/cabal-install-tutorial.html