GitHub上有直接通過腳本一鍵安裝Mono的腳本,具體參見 https://github.com/nathanb/iws-snippets/tree/master/mono-install-scripts/fedora。
1、安裝Mono的最新環境Mono-2.11
mkdir mono-2.11
cd mono-2.11
wget --no-check-certificate https://github.com/nathanb/iws-snippets/tree/master/mono-install-scripts/fedora/install_mono-2.11.sh
chmod 755 install_mono-2.11.sh
./install_mono-2.11.sh
2、在CentOS上設置Mono環境變量
安裝腳本將Mono安裝到了/opt/mono-2.11/,需要將Mono的目錄加入系統$PATH變量
方法一: 在/etc/profile文件中添加變量【對所有用戶生效(永久的)】
用VI在文件/etc/profile文件中增加變量,該變量將會對Linux下所有用戶有效,並且是“永久的”。
[root@SNDA-192-168-15-161 ~]# vi /etc/profile
在文件末尾加上如下兩行代碼
PATH=/opt/mono-2.11/bin:$PATH export PATH
要是剛才的修改馬上生效,需要執行以下代碼
[root@SNDA-192-168-15-161 ~]# source /etc/profile
方法二 :在/etc/profile.d/目錄下創建一個Mono的配置
創建一個新的mono.sh
在這個文件內初始化環境變量
export PATH=$PATH:/opt/mono-2.11/bin
要是剛才的修改馬上生效,需要執行以下代碼
[root@SNDA-192-168-15-161 profile.d]# source mono.sh
現在可以直接執行Mono 的命令了
[root@SNDA-192-168-15-161 profile.d]# mono -V
Mono JIT compiler version 2.11.3 (tarball Thu Oct 11 07:46:58 CST 2012)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
