(参见http://ocaml.org/docs/install.html)
$ wget http://www.ocamlpro.com/pub/opam_installer.sh
$ sh opam_installer.sh /usr/local/bin
最后提示:
During this initialisation, you can allow OPAM to add information to two
other files for best results. You can also make these additions manually
if you wish.
If you agree, OPAM will modify:
- ~/.bashrc (or a file you specify) to set the right environment
variables and to load the auto-completion scripts for your shell (bash)
on startup. Specifically, it checks for and appends the following line:
. ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
- ~/.ocamlinit to ensure that non-system installations of `ocamlfind`
(i.e. those installed by OPAM) will work correctly when running the
OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list
of include directories.
If you choose to not configure your system now, you can either configure
OPAM manually (instructions will be displayed) or launch the automatic setup
later by running:
`opam config setup -a`.
Do you want OPAM to modify ~/.bashrc and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bashrc)
[N/y/f] f /etc/profile
1. To configure OPAM in the current shell session, you need to run:
eval `opam config env`
2. To correctly configure OPAM for subsequent use, add the following
line to your profile file (for instance ~/.bashrc):
. /root/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
3. To avoid issues related to non-system installations of `ocamlfind`
add the following lines to ~/.ocamlinit (create it if necessary):
let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
;;
To use OCaml installed by OPAM, use
eval `opam config env`
as3:~#
as3:~# ocaml -version
The OCaml toplevel, version 4.01.0
as3:~#
as3:~# opam --version
1.1.0
(显示opam的版本为1.1.0,这表明opam安装成功。)
装完opam后,
opam update
opam install stog (这样就装好了stog)
(具体为:
as3:~# opam update
default Downloading https://opam.ocaml.org/urls.txt
default Downloading https://opam.ocaml.org/index.tar.gz
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Updating the cache of metadata (~/.opam/state.cache) ...
Everything is up-to-date.
as3:~# opam install stog
The following actions will be performed:
- install ocamlfind.1.4.0 [required by stog]
- install config-file.1.1 [required by stog]
- install ocamlnet.3.7.3 [required by stog]
- install xmlm.1.2.0 [required by stog]
- install ocamlrss.2.2.2 [required by stog]
- install xtmpl.0.7 [required by stog]
- install stog.0.9.0
7 to install | 0 to reinstall | 0 to upgrade | 0 to downgrade | 0 to remove
Do you want to continue ? [Y/n] y
=-=-= Installing ocamlfind.1.4.0 =-=-=
ocamlfind.1.4.0 Downloading http://pkgs.fedoraproject.org/lookaside/extras/ocaml-findlib/findlib
-1.4.tar.gz/5d1f8238c53964fdd14387b87b48b5d9/findlib-1.4.tar.gz
Copying ~/.opam/repo/default/packages//ocamlfind/ocamlfind.1.4.0/files/ocamlfind.install to
~/.opam/4.01.0/build/ocamlfind.1.4.0/
Building ocamlfind.1.4.0:
./configure -bindir /root/.opam/4.01.0/bin -sitelib /root/.opam/4.01.0/lib -mandir
/root/.opam/4.01.0/man -config /root/.opam/4.01.0/lib/findlib.conf
make all
make opt
make install
Installing ocamlfind.1.4.0.
=-=-= Installing config-file.1.1 =-=-=
config-file.1.1 Downloading https://forge.ocamlcore.org/frs/download.php/845/config-file-
1.1.tar.gz
Building config-file.1.1:
./configure --prefix /root/.opam/4.01.0
make all
make install
Installing config-file.1.1.
=-=-= Installing ocamlnet.3.7.3 =-=-=
ocamlnet.3.7.3 Downloading http://download.camlcity.org/download/ocamlnet-3.7.3.tar.gz
Copying ~/.opam/repo/default/packages//ocamlnet/ocamlnet.3.7.3/files/ocamlnet.install to
~/.opam/4.01.0/build/ocamlnet.3.7.3/
Building ocamlnet.3.7.3:
./configure -bindir /root/.opam/4.01.0/bin -disable-pcre -disable-gtk2 -disable-ssl -disable-
zip -disable-crypto -with-nethttpd
make all
make opt
make install
Installing ocamlnet.3.7.3.
=-=-= Installing xmlm.1.2.0 =-=-=
xmlm.1.2.0 Downloading http://erratique.ch/software/xmlm/releases/xmlm-1.2.0.tbz
Building xmlm.1.2.0:
./pkg/pkg-git
./pkg/build true
Installing xmlm.1.2.0.
[WARNING] unknown fields in /root/.opam/4.01.0/build/xmlm.1.2.0/xmlm.install: is your OPAM up-to
-date ?
=-=-= Installing ocamlrss.2.2.2 =-=-=
ocamlrss.2.2.2 Downloading http://zoggy.github.io/ocamlrss/ocamlrss-2.2.2.tar.gz
Building ocamlrss.2.2.2:
make
make install
Installing ocamlrss.2.2.2.
=-=-= Installing xtmpl.0.7 =-=-=
xtmpl.0.7 Downloading http://zoggy.github.com/xtmpl/xtmpl-0.7.tar.gz
Building xtmpl.0.7:
make all
make install
Installing xtmpl.0.7.
=-=-= Installing stog.0.9.0 =-=-=
stog.0.9.0 Downloading http://zoggy.github.com/stog/stog-0.9.0.tar.gz
Copying ~/.opam/repo/default/packages//stog/stog.0.9.0/files/stog.install to
~/.opam/4.01.0/build/stog.0.9.0/
Building stog.0.9.0:
make all
make install-lib
Installing stog.0.9.0.
as3:~# )
项目地址:https://github.com/zoggy/stog
http://zoggy.github.io/stog/
但没学会如何用stog来建立静态博客.
https://github.com/ocaml/opam-repository
The quickest way to get the latest opam up and working is to run this script:
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
This will simply check your architecture, download and install the proper pre-compiled binary, backup your opam data if from an older version, and run opam init
.
(If you have trouble with curl
, just download the script and run sh install.sh
)
We provide pre-compiled binaries for:
- Linux i686, amd64, arm7, arm64
- OSX (intel 64 bits, arm64)
OPAM的设置
OPAM is the package manager for OCaml. It is the recommended way to install the OCaml compiler and OCaml packages. Simply follow the OPAM install instructions.
Then, use opam to install an ocaml compiler. Example using the Bash shell and opam-2.0:
# environment setup
opam init
eval $(opam env)
# install given version of the compiler
opam switch create 4.12.0
eval $(opam env)
# check you got what you want
which ocaml
ocaml -version
from https://ocaml.org/docs/install.html
------------------------------------------