找回密码
 注册
搜索
查看: 5795|回复: 0

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
- I! V0 h4 p1 I.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。+ Z* j6 P8 v1 {; `/ n
下面就介绍让Apache支持ASP.NET的办法。0 ~6 i  M# E: l8 G

' \/ D6 K- m  \3 \+ u; `2 i7 d     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。+ j2 \2 h6 N$ U; [
6 m8 o, t4 D9 l. m( H$ \
     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:8 g; D1 y4 c. t- `) S
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
3 C0 L; G0 O# J& \7 Z5 z具体的安装过程请参阅其他文章,本文不再赘述。# t% i0 }- P5 P& X

+ L0 S+ `4 c3 y/ W     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:0 A* P$ q8 j& Z' y+ _& _" j: f
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi, A; V8 _5 b9 j! q, _6 E* ~* n" I# J( D
下载完成后双击打开,一路Next即可安装完成。
2 o. i1 l2 g* e  ]5 N6 D$ k4 t, J% U
0 B% b+ ?9 I& A9 p3 Z     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
- V! o2 t' [+ e7 ]1 ^/ @
. F1 g1 U. x& e" K#asp.net
6 Z# Z3 t" ]# SLoadModule aspdotnet_module "modules/mod_aspdotnet.so"; q% y/ p; s0 ]0 C. `$ t1 O

. r* y* c# d3 @AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
4 ?* K3 f4 V  v, e            licx rem resources resx soap vb vbproj vsdisco webinfo
, f2 K5 o! a- X' h/ f: |, V4 g+ o7 s# @/ w' k" T4 u
<IfModule mod_aspdotnet.cpp>
3 `! r/ N7 |% \' q( j) d7 ^7 i! K( M: M) u7 }1 B! n
  # Mount the ASP.NET example application+ C/ m4 N7 ~. A* v9 ~/ @
  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
2 @! m; h9 k; f& L$ M) g/ V5 `/ i, f" W- _, ?3 i3 @0 G
  # Map all requests for /active to the application files/ [! ^: ]! b4 i& f3 l
  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
! X4 y2 [  U& a
( |+ y( S( F1 b# G1 L; b7 ]  # Allow asp.net scripts to be executed in the active example
" k9 q" r* V( X6 c9 v  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">( x! t! Q8 n( o+ |3 Z! h6 P6 i
    Options FollowSymlinks ExecCGI8 _  j( q4 }- I# j' F" e
    Order allow,deny" y6 }, ?4 \) Y% i* @* c
    Allow from all
; z& @# W: C+ V# r    DirectoryIndex Default.htm Default.aspx
5 x7 w7 a" w( Y6 E9 T0 S  </Directory>$ ~) y4 P9 W3 v" T4 d7 [9 L# z

; ?- p4 J: W* `- T" T2 M1 i  # For all virtual ASP.NET webs, we need the aspnet_client files 8 t0 ^8 Z" O# _  O% |. o
  # to serve the client-side helper scripts.4 r( S9 z9 i$ K; W
  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \# F- D& f9 a" \# ]8 w& L# k
      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
) ^4 T# N+ T0 z, A  <Directory \
' l# z" G' i/ W' I6 V4 G7 \      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
, g+ R' N% p) I, ?  N! |    Options FollowSymlinks
0 ?& [* e" L  I. j6 J/ @    Order allow,deny
+ G% H4 ^& g3 w( W' b3 A& i6 w    Allow from all
+ l$ o1 d4 C6 h- W  </Directory>: }; h& c, K2 y7 d8 d
. x, S+ o4 p2 j. C
</IfModule>8 N( e/ L5 S) f% ?

: L) \3 S1 K6 Z     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。0 T6 b0 E* G: k6 I
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。  ^' i9 Y: F  T6 j. E
; E% Z) [) u- y. ?: k- I
     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|宁德市腾云网络科技有限公司 ( 闽ICP备2022007940号-5|闽公网安备 35092202000206号 )

GMT+8, 2026-2-10 03:33 , Processed in 0.023881 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表