|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。+ j m- P! h4 r: Q! |
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
/ P' R$ e( t; R" J( K2 }下面就介绍让Apache支持ASP.NET的办法。 u6 S& ~) N9 `+ z2 l8 F
" i0 B4 |) |3 R( ~; P, V 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
$ @0 g5 s w4 E4 ?
& r, f5 q: a. i5 @9 F1 H 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
1 `4 p8 L+ c! x/ L4 \http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi4 a% x0 Z/ P" i+ T' C m
具体的安装过程请参阅其他文章,本文不再赘述。
$ y+ D. f. h/ M, p) T! q' A& G8 J B
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
J: Q7 x S9 u U4 k4 I/ C0 Rhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
8 B- b- E b; s: R. a6 `, f5 [下载完成后双击打开,一路Next即可安装完成。
/ D& j7 A# O3 k/ p: H
3 D G5 R7 Q1 d 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:7 H) G& i. N4 o) M6 J, U
/ ^7 D1 A( d; X8 E9 a& a R#asp.net0 _% P* G0 Q# x; n" O3 f3 x/ A* g
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"$ t1 ], E) ~$ J1 F5 N4 ^ A/ c
$ {$ r0 O$ }$ `' x5 ^2 ~* KAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \; f! u2 S! H) I q! z2 \
licx rem resources resx soap vb vbproj vsdisco webinfo & N% J/ z X8 n" i1 g
) _1 { X! `" E# g4 d8 Z4 _9 |- Z<IfModule mod_aspdotnet.cpp>" R/ o$ j2 H" W( M
1 m' y" u/ W! {* c. N8 H6 q* \ # Mount the ASP.NET example application
, V( N/ `% a7 p) G+ v, }' P AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"6 z; ?# D6 S* R, O) _
/ }$ O$ v X0 A # Map all requests for /active to the application files: q' O; _5 ~4 j$ f$ {9 H @
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"0 }1 Q. A; R- f
; ?4 u0 ~0 c& ^: l& d3 ~) ^" r
# Allow asp.net scripts to be executed in the active example) O* u) p: w) ~9 U/ L4 z' ?
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
1 j' r" s0 ~6 N, l2 u$ ^: G, t Options FollowSymlinks ExecCGI- W3 H: v2 t( L/ M! n6 N- w+ }. {: q/ m
Order allow,deny* V4 D, x8 f5 D8 V1 k2 J1 V
Allow from all5 ?3 h5 y4 h. M9 v* c+ k
DirectoryIndex Default.htm Default.aspx
$ G w3 @0 a6 a& \! M </Directory>$ B$ |/ y+ H; L3 M& _% P% \
( w5 j( v7 C4 ?* }1 ?% F8 s
# For all virtual ASP.NET webs, we need the aspnet_client files 4 X" O) T: K2 z" |) C) n7 q
# to serve the client-side helper scripts.6 c- u1 s4 }* I" j/ c
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \/ P% k' b- b" Q9 u6 D, N! P% B) E
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
$ z) l3 K3 P& M/ }" w <Directory \
; J* I. T+ E) h( q4 y! Y "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles"># v. W$ s' ]1 L3 y' f$ m5 t2 W
Options FollowSymlinks
: s9 {2 o1 A. x+ r8 H8 h; K& C Order allow,deny
) z5 D3 B! H3 W# o, n. M3 Z Allow from all
8 I# F- @( _. ^% h0 ^0 {$ \ </Directory>
6 n3 n) J9 x4 E2 b1 g1 G% \* J# q( B: A2 D( Z. f2 a `
</IfModule>
' @7 X3 y, k6 R: _
0 J8 A9 d7 F+ j0 U/ I6 h1 F& p 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。& L2 b& c! U$ V/ E; p
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。. A- U: c$ h) l' b2 a, y
2 y5 g3 ]4 A+ j8 v( b
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|