|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。& W* Z; q# c+ g; L7 k" T. P
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
5 i. E9 Q7 w1 l1 {下面就介绍让Apache支持ASP.NET的办法。
3 s! ?8 \$ U0 c% V! k6 O+ O! r$ c
% B1 Q6 _- o7 D# ~, J# B0 O 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
$ N9 F2 ~5 }. H, n8 q
" y- Z: B+ @% b# j; E 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:/ W, s5 J i9 k( b) Q: x
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi I. Z0 g) r9 i" m2 a. n9 y
具体的安装过程请参阅其他文章,本文不再赘述。0 Q( b# j1 ?3 x. ^% Y( u5 x7 a
- G" N. J+ o3 k, c7 n1 t6 ]. o 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:3 s8 \7 |, j5 w! Z
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi6 R: q! C4 ^" |2 e, R% n! N( d
下载完成后双击打开,一路Next即可安装完成。/ l& { v# l! s! y
. Q" h. G% g$ R3 L; ~, B( ` 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
9 F' M( c* b% a$ G; K5 L6 @. {) c. e; _, a- K
#asp.net
: W, r5 g1 V x) H9 uLoadModule aspdotnet_module "modules/mod_aspdotnet.so". X+ o @5 F! \5 N, J
, F# V4 }0 `: S" _4 E. Q
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \$ S( v& `' S1 O& @$ |3 j
licx rem resources resx soap vb vbproj vsdisco webinfo
, {; b0 ?& i, N0 k
) Y* h# T* {/ H8 ]0 w' X( W' {" T<IfModule mod_aspdotnet.cpp>8 [- V$ d8 m* h# q. P0 Y
* L* `9 g2 Z j% t1 ^ # Mount the ASP.NET example application
" v0 c8 n* @! K AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"- _* m, z" l0 R2 m+ p
7 k( ?5 h& @ u # Map all requests for /active to the application files" e& j1 T B7 m% N
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"& @# I7 [3 L4 k% e; v1 C
: h. Y: W% t# d3 i+ F5 V" R
# Allow asp.net scripts to be executed in the active example
& B( S9 b0 K; Q7 c6 a3 m' z <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
9 S- c' D& K) F$ q' C) k8 | Options FollowSymlinks ExecCGI
4 Q9 H0 }7 ?1 k, p" q3 C* x Order allow,deny9 ?! a8 m% J; _' ^& T/ L# ~7 u' l7 \
Allow from all O9 ?9 f2 N" D9 O1 }5 N8 d7 E
DirectoryIndex Default.htm Default.aspx
) F. |0 S( H; i </Directory># E) @- |9 x- V0 U' v! ^, I) I
/ W! T2 S5 ^% F8 V2 w- B8 @ # For all virtual ASP.NET webs, we need the aspnet_client files : z% m+ N9 Z6 q+ r d
# to serve the client-side helper scripts.
% H. l Z( w& {7 D8 }; b AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
L& f1 i9 v# l: H "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
3 e4 d% L& Z; I7 h9 a1 { <Directory \
/ D2 S6 v& Q0 o U "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">) m q# k& o% B1 u4 }: [5 V2 t
Options FollowSymlinks
5 G4 c5 I) ^" A$ X( G: _5 M Order allow,deny2 W ]' d. ~" E- z+ n* n
Allow from all
* ~1 @- _3 F* I' ~; V4 m </Directory>5 Y; @5 |7 t( @1 O4 b- {1 l
- Z& p3 R4 ]. e w1 M2 Z</IfModule>" P1 [8 h0 x8 V# P6 W/ \* v% s$ a
0 `, ]- B. f( o4 X 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。6 @/ K- y( z# {/ O7 k ]; p
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
" L+ e5 K7 }. |& Q4 d; X) U' I. ~
6 q5 \$ J/ g, ]* v9 K* c8 k 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|