FreeBSD 9.0上運作 .net aspx動態網頁
Update:2012.09.19
- 更新Freebsd
# freebsd-update fetch
# freebsd-update install
- 更新ports tree源路徑
# portsnap fetch extract
- 更新ports tree
# cd /usr
# rehash
# csup -L 2 ports-supfiles
- 更新Ports的索引檔
# cd /usr/ports ; make fetchindex
- 確認系統已安裝以下程式或伺服器
libtool 2.4.x
gcc 4.6.x
perl-5.12.4_3
Apache server
Webmin server
確認方法:
# pkg_info | grep webmin
出現已下訊息則表示已安裝
webmin-1.590_1 Web-based interface for system administration for Unix |
- 在mono project的網站有關於在FreeBSD上使用Mono的介紹:http://www.mono-project.com/Mono:FreeBSD
其中說到了獲取mono的兩種方式:FreeBSD ports tree 和 BSD# ports tree,同樣BSD# ports tree中也包括了BSD# project的兩個版本:穩定版本 mono 和開發版本 mono-devel
可以通過BSD#的ports tree合併工具mono-merge把BSD# prots tree合併到本地的FreeBSD ports tree中:
- BSD#估計採用了subversion進行源碼管理,需要先安裝subversion:
安裝subversion
# cd /usr/ports/devel/subversion ;; make install clean
如果安裝subversion過程中提如下提示:
You should build `devel/apr' with db4 support to use subversion with it. Please rebuild `devel/apr' with option `' and try again. Or you can disable db4 support. Only 'fs' repository backend will be available. To disable db4 support, define WITHOUT_BDB. |
則重新安裝配置一下apr,啟用apr for BDB,再重新安裝subversion即可:
# cd /usr/ports/devel/apr
|
- 安裝mono-merge
# cd /tmp # wget http://bsd-sharp.googlecode.com/files/mono-merge.tar.gz # tar zxvf mono-merge.tar.gz # cd mono-merge # make install # cd .. ; rm -R mono-merge ; rm mono-gerge.tar.gz |
- 合併BSD# ports tree
合併穩定版ports tree:
# mono-merge
合併開發版ports tree:
# mono-merge -D
如果沒有安裝subversion,執行mono-merge時會提示錯誤:
# mono-merge ===> Checking out the FreeBSD-ports module. svn: not found Failed to check out the BSD# ports tree. |
10.安裝.Net所需的Freamwork Mono程式,須依序安裝,否則會遇到X11錯誤:
# cd /usr/ports/x11-toolkits/gtk20
# make -DWITHOUT_X11 install clean
ports tree合併完成後,進入/usr/ports/lang/mono目錄,安裝mono最新版本。
# cd /usr/ports/lang/mono ;; make install clean
安裝完成後執行# mono -V可以看到已經是mono 2.11.1。
# mono -V Mono JIT compiler version 2.11.1 (tarball Mon Aug 27 14:47:06 CST 2012) Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: normal Notification: kqueue Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: Included Boehm (with typed GC and Parallel Mark) |
# cd /usr/ports/lang/mono-basic ;; make install clean
# cd /usr/ports/devel/mono-addins ;; make install clean
# cd /usr/ports/devel/mono-tools ;; make install clean
11.安裝Apache2需要載入的Mod-Mono模組
# cd /usr/ports/www/mod_mono ; make install clean
12.安裝.net framework所需的libraries
# cd /usr/ports/x11-toolkits/libgdiplus ;; make BATCH=yes install clean
13.修改mod_mono.conf
# vi /usr/local/etc/apache22/Includes/mod_mono.conf
加入以下設定 <IfModule !mod_mono.c> LoadModule mono_module /usr/local/libexec/apache22/mod_mono.so MonoAutoApplication enabled ForceType application/x-asp-net MonoServerPath = /usr/local/bin/mod-mono-server4 </IfModule> |
14.測試.net網頁是否可執行
將mono的測試網頁拷貝到自己的網頁目錄中
# cp -fR /usr/local/lib/xsp/test /usr/web
重新啟動apache
# /usr/local/etc/rc.d/apache22 restart
使用流覽器查看網頁伺服器是否正常動作,若有網頁出現表示可正常載入asp網頁
以流覽器開啟網頁http://192.168.1.21/test/