|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
3 `0 }/ z( y& N- r6 i2 [# U/ p.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。# J9 [2 m& D) d
下面就介绍让Apache支持ASP.NET的办法。
- N) K- @, j6 c# z& `- T$ k4 ~0 b! U: e) J/ v2 E b3 J. y( `+ o! k
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。/ ~* A" h& a0 P7 a; e B9 c
Z1 A) N _3 k! T
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:9 j; K, y' m K8 D+ g0 X0 `1 z
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi6 K0 p/ l# X4 B6 ~- M! f' ^' {
具体的安装过程请参阅其他文章,本文不再赘述。
- c+ C, q7 r# g9 X
& [* a8 n( Q* j9 b- x T: d/ `$ H5 T 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:5 F4 i, b( c2 G8 r# e
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi, s# M1 z/ f, c& A2 k
下载完成后双击打开,一路Next即可安装完成。' l9 j& P- C( h# a6 w/ D. x
5 F+ F: T3 s: V; c
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
9 P7 x: t: o+ r/ P! F6 X! l
3 F! k. p0 N' o- ^4 j+ T1 V#asp.net" I4 e% s1 \- M: \' y/ A/ c, S0 D
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"9 C# I+ l9 _7 o
3 E; j) {7 e0 H# U* c) ~7 CAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
( M# i. s* u. H( M6 g3 { licx rem resources resx soap vb vbproj vsdisco webinfo
3 r& L8 v$ J+ v9 y* @3 _2 F
4 C! x9 D; n: p5 T5 I1 [<IfModule mod_aspdotnet.cpp>
- j2 s' T& T) Z9 Y
& M/ U! K0 F$ m. K' l # Mount the ASP.NET example application8 U: @+ w2 L# g+ I0 y$ [; V
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
$ n: P. t4 e# C" t, @) N- _/ E# {( O- p7 Y
# Map all requests for /active to the application files
5 U1 u( r- r m! }) `5 E! y Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
$ h0 ?6 O3 N+ i, T3 e1 J
6 X1 f- y1 N' Y# |0 B6 M # Allow asp.net scripts to be executed in the active example
1 o3 f' D3 a/ Z) l- K <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
, q) D z9 r# K0 I9 e Options FollowSymlinks ExecCGI% C7 H9 W, B2 p2 ]( p$ |
Order allow,deny# K* i* U' S" S2 L" g4 I
Allow from all( {/ h8 u6 j: j& I" e
DirectoryIndex Default.htm Default.aspx- w2 V3 b3 ~; K5 c
</Directory>1 L, ]1 E6 ^# A7 n7 Q
. V& H+ V0 Z5 A' d4 C # For all virtual ASP.NET webs, we need the aspnet_client files
' C+ e, M+ ]1 C: B& f K5 Z. R # to serve the client-side helper scripts.
- }$ l9 |. o0 N8 y; f AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
7 p# c* i4 B4 l "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
; X I; H' {# J0 s, Y2 a <Directory \& d* ~" a% m1 J* Q, K
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">8 |4 ~4 e) T( Q; M8 u; R L
Options FollowSymlinks
. w1 D' ~* a6 _4 [ Order allow,deny0 h( s" e/ d: f& M. ~) `
Allow from all; E1 o" C" B7 C7 J
</Directory>
8 O& c( A9 L" `+ a4 l0 P. b
V0 [* J4 V0 t Q6 Z3 N1 q</IfModule>
& D: ]- L& q8 L$ \ t* ~0 f) r9 y0 L: Z8 n
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
- W- a# _) d( z4 H- i) F( {现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。9 Y$ C, K1 _( G: g/ [
8 e% r z2 L, @5 f! _0 X1 ?2 @
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|