前言
經過嘗試網上各種安裝mono的技術貼,這個安裝過程經歷了大約2周,嘗試了各個版本,幾目前博客所描述的所有安裝方式。以下內容的安裝方式可以為你嘗試不同版本的mono。并非正式環境安裝標準方式安裝。
1、安裝需要的庫
yum -y install wget glib2-devel libtiff libtiff-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel libX11 libX11-devel freetype freetype-devel fontconfig fontconfig-devel libexif libexif-devel gcc-c++ gettext unzip zip bzip2 bzip2-devel curl-devel gtk2-devel boost-devel
2、添加rpm源
rpm --import "http://keyserver.Ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"yum-config-manager --add-repo http://jenkins.mono-PRoject.com/repo/centos/
3、查找可用版本
yum search mono-snapshot
4、選擇安裝最新版本快照
yum -y install mono-snapshot-latest
ps:如果想安裝某版本的快照命令為
yum -y install mono-snapshot-XXXXXXXXX
5、查看可用的Mono快照
mono-snapshot
顯示結果如下:
This script will help you to set up your environment to use asnapshot package of Mono. To use it, run: . mono-snapshot APP/VERYou have the following possible combinations of APP/VER: mono/20150520032320Calling APP without specifying VER will load the latest version
6、執行指定快照
mono-snapshot mono或者mono-snapshot mono/XXXXXXXXX
顯示結果:
[mono-20150520032320][root@localhost ~]# mono-20150520032320表示mono所使用的快照
7、確認Mono是否安裝成功
mono --version
顯示結果:
Mono JIT compiler version 4.1.0 (tarball Tue May 19 23:45:50 EDT 2015)Copyright (C) 2002-2014 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: sgen
8、在CentOS上設置Mono環境變量
借助find / -name 'libMonoPosixHelper.so' 命令查找版本的安裝地址;
find / -name 'libMonoPosixHelper.so'/opt/mono-20150520032320/lib/libMonoPosixHelper.so
記下/opt/mono-20150520032320 (下文中將會用到)
如果安裝多個版本則會有多個記錄。
以下內容主要參考張善友的文章(http://www.CUOXin.com/shanyou/archive/2012/10/11/2720597.html)
安裝腳本將Mono安裝到了/opt/mono-20150520032320/,需要將Mono的目錄加入系統$PATH變量
方法一: 在/etc/profile文件中添加變量【對所有用戶生效(永久的)】用VI在文件/etc/profile文件中增加變量,該變量將會對Linux下所有用戶有效,并且是“永久的”。
vi /etc/profile
在文件末尾加上如下兩行代碼
PATH=/opt/mono-20150520032320/bin:$PATH export PATH
修改生效,需要執行以下代碼(否則重啟reboot)
source /etc/profile
方法二 :在/etc/profile.d/目錄下創建一個Mono的配置
cd /etc/profile.d/
創建一個新的mono.sh
vi mono.sh
在這個文件內寫入以下內容
export PATH=$PATH:/opt/mono-20150520032320/bin
路徑中的“mono-20150520032320”則是有上面的查看得到,如果需要配置更新版本則路徑即可。
修改生效,需要執行以下代碼
source mono.sh
現在可以直接執行Mono 的命令了
mono -VMono JIT compiler version 4.1.0 (tarball Tue May 19 23:45:50 EDT 2015)Copyright (C) 2002-2014 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: sgen
執行結果一致。Mono安裝完成。
新聞熱點
疑難解答