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
:$PATHexport 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)
Running ASP.NET MVC4 on Ubuntu 12.04