在 Ubuntu 12.04 安裝 Mono 3.0.6 跑 Visual WebGUI 6.3.17

我一直使用 Visual WebGUI 6.3.17 開發軟件,運行的平台當然就是 Windows。由於想移植至 Linux 最近花了點時間測試 Mono,以下就是安裝的過程。

1. 安裝 Ubuntu 12.04

01

什麼 package 也不要選,第一次 boot 就請更新一下 Ubuntu:

apt-get update

apt-get upgrade

2. 安裝 Apache2

apt-get install apache2

3. 安裝 Mono 3.0.6

利用有心人的 Debian package 安裝會比較容易 (參考這個網頁

用 vi 修改 /etc/apt/sources.list,加上一行指示 deb http://debian.meebey.net/experimental/mono /,如圖:

02

apt-get update

apt-get install mono-complete

完成後就可以測試一下 Mono 的版本是否 v3.0.6 (是目前最新的版本了):

mono -V

03

4. 安裝 Mod_Mono(可以參考這個網頁

/etc/init.d/apache2 stop
apt-get install libapache2-mod-mono
apt-get install mono-apache-server2
a2enmod mod_mono
/etc/init.d/apache2 start

至此 Mono 就已經安裝完成,接下來就是安裝 Visual WebGUI 的 web project 做測試。

5. 利用 mount 接駁 Windows 的 Shared folder 抄入已 compiled 的 project 檔案

首先安裝 cifs: apt-get install cifs-utils

建立 mount 用的檔案夾: mkdir /mnt/shared

5.1 Manual mount(logout 後消失)

mount.cifs //192.168.12.140/Shared /mnt/shared -o username=login_username,password=login_password,iocharset=utf8,file_mode=0777,dir_mode=077

192.168.12.140 是你台 Windows 的 IP Number

Shared 是你在 Windows 設定的 Shared folder 的名稱

如果順利 mounted,你就可以在 /mnt/shared 看到你台 Windows 的 files:

04

5.2 Automount(一開機就會自動 mount)

要用 vi 修改 /etc/fstab,加上一行:

//server/share /mnt/mountname cifs username=server_user,password=user_password,iocharset=utf8,file_mode=0777,dir_mode=07‌​77 0 0

例如:

//192.168.12.140/Shared /mnt/shared cifs username=login_username,password=login_password,iocharset=utf8,file_mode=0777,dir_mode=077 0 0

6. 設定這個 website 在 mod_mono 要用到的 conf 檔案

可以參考這個網頁,我用一個名為 xPort3 的 WebApps 做測試:

05

  Alias /xPort3 "/var/www/xPort3"
  # MonoServerPath can be changed to specify which version of ASP.NET is hosted
  # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0
  # For SUSE Linux Enterprise Mono Extension, uncomment the line below:
  # MonoServerPath xPort3 "/opt/novell/mono/bin/mod-mono-server2"
  # For Mono on openSUSE, uncomment the line below instead:
  MonoServerPath xPort3 "/usr/bin/mod-mono-server2"

  # To obtain line numbers in stack traces you need to do two things:
  # 1) Enable Debug code generation in your page by using the Debug="true"
  #    page directive, or by setting <compilation debug="true" /> in the
  #    application's Web.config
  # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging
  MonoDebug xPort3 true

  # The MONO_IOMAP environment variable can be configured to provide platform abstraction
  # for file access in Linux.  Valid values for MONO_IOMAP are:
  #    case
  #    drive
  #    all
  # Uncomment the line below to alter file access behavior for the configured application
  MonoSetEnv xPort3 MONO_IOMAP=all
  #
  # Additional environtment variables can be set for this server instance using
  # the MonoSetEnv directive.  MonoSetEnv takes a string of 'name=value' pairs
  # separated by semicolons.  For instance, to enable platform abstraction *and*
  # use Mono's old regular expression interpreter (which is slower, but has a
  # shorter setup time), uncomment the line below instead:
  # MonoSetEnv xPort3 MONO_IOMAP=all;MONO_OLD_RX=1

  MonoApplications xPort3 "/xPort3:/var/www/xPort3"
  <Location "/xPort3">
    Allow from all
    Order allow,deny
    MonoSetServerAlias xPort3
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI ".(?:gif|jpe?g|png)$" no-gzip dont-vary
  </Location>
  <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
  </IfModule>

conf 檔案造好後就重啟了 Apache,然後就可以在另外一台 PC 進行測試:

06

大部份的功能是正常的,可以直接運行。

7. Optional 安裝 MonoDevelop 方便在 Server 直接修改 project code (參考網頁

add-apt-repository ppa:keks9n/monodevelop-latest
apt-get update
apt-get install monodevelop-latest

(注意: MonoDevelop 是需要先安裝 Ubuntu Desktop 的)