自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux操作系統(tǒng)中運(yùn)行ASP.NET 4

開(kāi)發(fā) 后端
我們之前已經(jīng)討論過(guò)在openSUSE 11.3 操作系統(tǒng)配置ASP.NET 4開(kāi)發(fā)環(huán)境的問(wèn)題了,下面將更詳細(xì)的介紹后續(xù)步驟。

在openSUSE下ASP.NET 4開(kāi)發(fā)環(huán)境配置》中已經(jīng)配置好了 openSUSE 11.3 操作系統(tǒng)。

現(xiàn)在,我們進(jìn)入“GNOME 終端”,使用 ifconfig 命令驗(yàn)證一下本虛擬的 IP 地址就是一開(kāi)始我們?cè)趯拵酚善髦袨樗峙涞撵o態(tài)地址。

  1. ben@linux-nyhn:~> /sbin/ifconfig  
  2. eth0      Link encap:Ethernet  HWaddr 08:00:27:51:5B:0B    
  3.           inet addr:192.168.1.251  Bcast:192.168.1.255  Mask:255.255.255.0  
  4.           inet6 addr: fe80::a00:27ff:fe51:5b0b/64 Scope:Link  
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  6.           RX packets:853 errors:0 dropped:0 overruns:0 frame:0  
  7.           TX packets:807 errors:0 dropped:0 overruns:0 carrier:0  
  8.           collisions:0 txqueuelen:1000   
  9.           RX bytes:853227 (833.2 Kb)  TX bytes:90376 (88.2 Kb)  
  10.  
  11. lo        Link encap:Local Loopback    
  12.           inet addr:127.0.0.1  Mask:255.0.0.0  
  13.           inet6 addr: ::1/128 Scope:Host  
  14.           UP LOOPBACK RUNNING  MTU:16436  Metric:1  
  15.           RX packets:22 errors:0 dropped:0 overruns:0 frame:0  
  16.           TX packets:22 errors:0 dropped:0 overruns:0 carrier:0  
  17.           collisions:0 txqueuelen:0   
  18.           RX bytes:1300 (1.2 Kb)  TX bytes:1300 (1.2 Kb)  
  19.  
  20. ben@linux-nyhn:~> sudo vim /etc/hosts 

如上所示,再使用 vim 編輯器編輯 /etc/hosts 文件,增加一個(gè)域名 ben.skyiv.com,如下圖所示:

注意上圖中的 IP 地址必須是 127.0.0.1,而不能是 192.168.1.251。在宿主機(jī)的 Windows Vista 操作系統(tǒng)中以管理員身份進(jìn)入命令提示符,使用記事本編輯 C:\Windows\System32\drivers\etc\hosts 文件,增加一個(gè)同樣的域名 ben.skyiv.com,注意此時(shí) IP 地址必須是 192.168.1.251,而不能是 127.0.0.1,如下圖所示:

我們的 openSUSE 11.3 操作系統(tǒng)已經(jīng)安裝好了 apache 軟件,但尚未啟用,如下所示:

  1. ben@linux-nyhn:~> sudo /sbin/service apache2 status  
  2. Checking for httpd2:                                              unused 

那么,現(xiàn)在,讓我們?cè)O(shè)置 apache 為開(kāi)機(jī)隨系統(tǒng)啟動(dòng),并且現(xiàn)在就啟動(dòng)它吧:

  1. ben@linux-nyhn:~> sudo /sbin/chkconfig -add apache2  
  2. apache2                   0:off  1:off  2:off  3:on   4:off  5:on   6:off  
  3. ben@linux-nyhn:~> sudo /sbin/service apache2 start  
  4. Starting httpd2 (prefork)                                            done  
  5. ben@linux-nyhn:~> sudo /sbin/service apache2 status  
  6. Checking for httpd2:                                              running 

現(xiàn)在讓我們?cè)谒拗鳈C(jī)的 Windows Vista 操作系統(tǒng)的谷歌瀏覽器中打開(kāi) ben.skyiv.com 網(wǎng)站試試看吧:

如上圖所示,我們的 Apache 2.2.15 已經(jīng)正常工作在 Linux/SUSE 操作系統(tǒng)上了。只不過(guò)現(xiàn)在該網(wǎng)站還沒(méi)有內(nèi)容而已。

在 openSUSE 操作系統(tǒng)中,Apache 的默認(rèn)文檔是放在 /srv/www/htdocs 目錄下的。

openSUSE 操作系統(tǒng)已經(jīng)為每個(gè)用戶(hù)建立了 public_html 目錄,例如我的用戶(hù)就是 /home/ben/public_html 目錄,用以放置該用戶(hù)的網(wǎng)站的內(nèi)容??梢酝ㄟ^(guò) ben.skyiv.com/~ben 訪問(wèn),這里 ben 是我的用戶(hù)名,如下圖所示:

從上圖中可以看出,這個(gè)目錄是空的,需要用戶(hù)自己放里放東東。那么,我們就編寫(xiě)如下一個(gè) index.html 吧:

  1. ben@linux-nyhn:~> cd public_html  
  2. ben@linux-nyhn:~/public_html> vim index.html 

再次在 Windows Vista 操作系統(tǒng)中訪問(wèn) ben.skyiv.com/~ben 網(wǎng)頁(yè):

現(xiàn)在讓我們來(lái)看看 mono 的版本:

  1. ben@linux-nyhn:~> mono --version  
  2. Mono JIT compiler version 2.6.4 (tarball Mon Jul  5 13:53:45 UTC 2010)  
  3. Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com  
  4.     TLS:           __thread  
  5.     GC:            Included Boehm (with typed GC and Parallel Mark)  
  6.     SIGSEGV:       altstack  
  7.     Notifications: epoll  
  8.     Architecture:  amd64  
  9.     Disabled:      none  
  10. ben@linux-nyhn:~>   
  11. ben@linux-nyhn:~> gmcs --version  
  12. Mono C# compiler version 2.6.4.0 

這個(gè) mono 2.6.4 的版本太低了。根據(jù) mono 官方下載頁(yè)面的指示,按如下步驟進(jìn)行升級(jí):

  1. ben@linux-nyhn:~> sudo zypper addrepo http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.3 mono-stable  
  2. 正在添加安裝源 'mono-stable' [done]  
  3. Repository 'mono-stable' successfully added  
  4. Enabled: Yes  
  5. Autorefresh: No  
  6. URI: http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.3  
  7.  
  8. ben@linux-nyhn:~> sudo zypper refresh --repo mono-stable  
  9. Retrieving repository 'mono-stable' metadata [done]  
  10. 正在構(gòu)建 'mono-stable' 安裝源緩存 [done]  
  11. Specified repositories have been refreshed.  
  12. ben@linux-nyhn:~> zypper dist-upgrade --repo mono-stable 
  13. =================> 在這里進(jìn)行漫長(zhǎng)的升級(jí) <=================  
  14. ben@linux-nyhn:~>  

升級(jí)完成,再次查看 mono 的版本:

  1. ben@linux-nyhn:~> mono --version  
  2. Mono JIT compiler version 2.8.1 (tarball Fri Nov 12 14:37:21 UTC 2010)  
  3. Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com  
  4.     TLS:           __thread  
  5.     SIGSEGV:       altstack  
  6.     Notifications: epoll  
  7.     Architecture:  amd64  
  8.     Disabled:      none  
  9.     Misc:          debugger softdebug   
  10.     LLVM:          yes(2.8svn-mono)  
  11.     GC:            Included Boehm (with typed GC and Parallel Mark)  
  12. ben@linux-nyhn:~> dmcs --version  
  13. Mono C# compiler version 2.8.1.0 

果然已經(jīng)升級(jí)到最新的 mono 2.8.1 版本了。

Apache mod_mono configuration tool 網(wǎng)頁(yè)可以生成運(yùn)行 ASP.NET 所需要的 Apache 軟件的配置文件,如下圖所示:

生成的 ben.skyiv.com.conf 文件如下所示:

  1. <virtualhost *:80> 
  2.   ServerName ben.skyiv.com  
  3.   DocumentRoot /home/ben/www  
  4.   # MonoServerPath can be changed to specify which version of ASP.NET is hosted  
  5.   # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0  
  6.   # For SUSE Linux Enterprise Mono Extension, uncomment the line below:  
  7.   # MonoServerPath ben.skyiv.com "/opt/novell/mono/bin/mod-mono-server2"  
  8.   # For Mono on openSUSE, uncomment the line below instead:  
  9.   MonoServerPath ben.skyiv.com "/usr/bin/mod-mono-server2"  
  10.  
  11.   # To obtain line numbers in stack traces you need to do two things:   
  12.   # 1) Enable Debug code generation in your page by using the Debug="true"   
  13.   #    page directive, or by setting  in the   
  14.   #    application's Web.config  
  15.   # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging  
  16.   MonoDebug ben.skyiv.com true  
  17.     
  18.   # The MONO_IOMAP environment variable can be configured to provide platform abstraction  
  19.   # for file access in Linux.  Valid values for MONO_IOMAP are:  
  20.   #    case  
  21.   #    drive  
  22.   #    all  
  23.   # Uncomment the line below to alter file access behavior for the configured application  
  24.   MonoSetEnv ben.skyiv.com MONO_IOMAP=all 
  25.   #  
  26.   # Additional environtment variables can be set for this server instance using   
  27.   # the MonoSetEnv directive.  MonoSetEnv takes a string of 'name=value' pairs   
  28.   # separated by semicolons.  For instance, to enable platform abstraction *and*   
  29.   # use Mono's old regular expression interpreter (which is slower, but has a  
  30.   # shorter setup time), uncomment the line below instead:  
  31.   # MonoSetEnv ben.skyiv.com MONO_IOMAP=all;MONO_OLD_RX=1 
  32.  
  33.   MonoApplications ben.skyiv.com "/:/home/ben/www"  
  34.   <location "/"> 
  35.     Allow from all  
  36.     Order allow,deny  
  37.     MonoSetServerAlias ben.skyiv.com  
  38.     SetHandler mono  
  39.     SetOutputFilter DEFLATE  
  40.     SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary  
  41.   </location> 
  42.   <ifmodule mod_deflate.c> 
  43.     AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript  
  44.   </ifmodule> 
  45. </virtualhost> 

這個(gè) ben.skyiv.com.conf 文件需要放在 /etc/apache2/conf.d 目錄下:

  1. ben@ben:~> ll /etc/apache2/conf.d  
  2. 總計(jì) 8  
  3. -rw-r--r-- 1 ben  users 2037 01-04 01:21 ben.skyiv.com.conf  
  4. -rw-r--r-- 1 root root  1239 10-01 02:12 mod_mono.conf 

然后創(chuàng)建 /home/ben/www 目錄,并重啟 Apache 服務(wù):

  1. ben@ben:~> mkdir www  
  2. ben@ben:~> sudo /etc/init.d/apache2 restart  
  3. Syntax OK  
  4. Shutting down httpd2 (waiting for all children to terminate)      done  
  5. Starting httpd2 (prefork)                                         done  
  6. ben@ben:~>  

現(xiàn)在讓我們建立一個(gè)網(wǎng)站:

  1. ben@ben:~> cd www  
  2. ben@ben:~/www> vim index.html 

在 openSUSE 11.3 操作系統(tǒng)中訪問(wèn) ben.skyiv.com 網(wǎng)站,如下圖所示:

點(diǎn)擊上圖中的“服務(wù)器信息”,出現(xiàn)“The resource cannot be found”錯(cuò)誤:

這是預(yù)料之中的,因?yàn)槲覀冞€沒(méi)有編寫(xiě) info.aspx 文件呢。從上圖中可以看出,ASP.NET 是 2.0 版的。

現(xiàn)在,我們修改 /etc/apache2/conf.d/ben.skyiv.com.conf 文件,如下所示:

  1. ben@ben:~/www> sudo vim /etc/apache2/conf.d/ben.skyiv.com.conf 

如上圖所示,將 mod-mono-server2 改為 mod-mono-server4 。然后重啟 Apache 服務(wù):

  1. ben@ben:~> sudo /etc/init.d/apache2 restart  
  2. Syntax OK  
  3. Shutting down httpd2 (waiting for all children to terminate)      done  
  4. Starting httpd2 (prefork)                                         done  
  5. ben@ben:~>  

然后重新訪問(wèn) ben.skyiv.com/aspx/info.aspx 網(wǎng)頁(yè):

 

從上圖中可以看出,已經(jīng)運(yùn)行在 ASP.NET 4 了。

 

現(xiàn)在,讓我們來(lái)編寫(xiě) info.aspx 程序吧:

  1. ben@linux-nyhn:~/www> mkdir aspx src bin  
  2. ben@linux-nyhn:~/www> vim aspx/info.aspx  
  3. ben@linux-nyhn:~/www> vim src/info.aspx.cs  
  4. ben@linux-nyhn:~/www> vim src/info.rsp 

網(wǎng)頁(yè)文件 aspx/info.aspx 的內(nèi)容如下所示:

  1.  <%@ Page Language="C#" inherits="Skyiv.Ben.Web.InfoPage" %> 
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  3.  <html xmlns="http://www.w3.org/1999/xhtml" > 
  4.  <head runat="server"> 
  5.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
  6.   <title>服務(wù)器信息</title> 
  7. </head> 
  8. <body> 
  9.  <form id="form1" runat="server"> 
  10.   <a href="http://ben.skyiv.com">返回</a> 
  11.  <hr /> 
  12.  <asp:GridView id="dgMain" runat="Server" > 
  13.  <AlternatingRowStyle BackColor="#FFFFCD" /> 
  14.      <HeaderStyle BackColor="#AAAADD" /> 
  15.    </asp:GridView> 
  16.    </form> 
  17.  </body> 
  18.  </html> 

對(duì)應(yīng)的 C# 源程序 src/info.aspx.cs 的內(nèi)容如下所示:

  1. using System;  
  2. using System.Data;  
  3. using System.Web.UI;  
  4. using System.Web.UI.WebControls;  
  5.  
  6.  namespace Skyiv.Ben.Web  
  7.  {  
  8.   public class InfoPage : Page  
  9.  {  
  10.  protected GridView dgMain;  
  11.    public void Page_Load(object sender, EventArgs e)  
  12.    {  
  13.      if (IsPostBack) return;  
  14.       dgMain.DataSource = GetInfo();  
  15.       dgMain.DataBind();  
  16.      }  
  17.    DataTable GetInfo()  
  18.      {  
  19.       DataTable dt = new DataTable();  
  20.       dt.Columns.Add("項(xiàng)目"typeof(string));  
  21.        dt.Columns.Add("內(nèi)容"typeof(string));  
  22.      AddRow(dt, "操作系統(tǒng)", Environment.OSVersion);  
  23.      AddRow(dt, "公共語(yǔ)言運(yùn)行庫(kù)", Environment.Version);  
  24.       return dt;  
  25.      }  
  26.     void AddRow(DataTable dt, string name, object value)  
  27.    {  
  28.      DataRow dr = dt.NewRow();  
  29.      dr[0] = name;  
  30.      dr[1] = value.ToString();  
  31.     dt.Rows.Add(dr);  
  32.     }  
  33.    }  
  34.   } 

編譯響應(yīng)文件 src/info.rsp 的內(nèi)容如下所示:

  1. -out:../bin/info.dll  
  2. -t:library  
  3. -r:System.Data  
  4. -r:System.Web  
  5. info.aspx.cs 

然后就是使用以下命令進(jìn)行編譯了:

  1. ben@linux-nyhn:~/www> cd src  
  2. ben@linux-nyhn:~/www/src> dmcs @info.rsp 

編譯完成,網(wǎng)站的運(yùn)行效果如下圖所示:

至此,我們成功地在 Linux 操作系統(tǒng)中運(yùn)行 ASP.NET 4。

原文鏈接:http://www.cnblogs.com/skyivben/archive/2011/01/04/1925385.html

  1. 詳解ASP.NET MVC 3 beta新特性
  2. ASP.NET MVC 3讓依賴(lài)注入實(shí)現(xiàn)得更簡(jiǎn)單
  3. 詳解ASP.NET MVC 3 beta新特性
  4. ASP.NET MVC 3新特性與NuPack功能詳解
  5. .NET開(kāi)發(fā)人員應(yīng)該關(guān)注的七個(gè)開(kāi)源項(xiàng)目

 

責(zé)任編輯:彭凡 來(lái)源: 博客園
相關(guān)推薦

2009-07-30 13:28:55

ASP.NET中的ja

2010-01-08 11:04:06

ASP.NET 4SEO

2009-08-05 17:54:04

ASP.NET運(yùn)行模式

2009-07-28 17:02:10

ASP.NET運(yùn)行環(huán)境

2009-10-26 15:55:43

URL Routing

2011-11-22 09:32:39

ASP.NET

2009-08-03 14:22:33

什么是ASP.NET

2009-07-28 17:17:19

ASP.NET概述

2009-12-22 16:23:12

Linux操作系統(tǒng)

2009-07-22 17:45:35

ASP.NET教程

2009-07-21 11:11:44

刪除CookieASP.NET

2009-07-24 10:10:22

ASP.NET

2009-07-24 16:17:42

WebRequestEASP.NET

2009-08-04 12:29:57

ViewState概念ASP.NET

2009-07-27 09:31:06

定義JavaScripASP.NET

2009-07-27 15:25:40

aspx頁(yè)面ASP.NET

2009-07-22 16:34:36

使用T4ASP.NET MVC

2009-07-27 12:22:03

ASP.NET和ASPASP.NET入門(mén)教程

2010-06-25 08:51:46

ASP.NET MVC

2009-08-10 13:32:15

ASP.NET TimASP.NET組件設(shè)計(jì)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)