|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
9 b8 T" c& K4 }9 A& J7 G' t.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。+ R; M4 z& p) A
下面就介绍让Apache支持ASP.NET的办法。
$ B5 [1 k+ B- e0 c: Q2 u7 c5 E% a/ X1 D7 D# Z' M k) h; n$ \. P
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
6 O' o( ]+ B5 ~7 D3 {4 {" B; g, U) \: o* |& T" W5 P4 e( r0 b
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
L7 m" e0 z# |http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
# G- v# n' Y# K: ^/ l; o7 ~具体的安装过程请参阅其他文章,本文不再赘述。
$ ?3 Y: \0 H6 U9 F0 _7 ]* i1 p, q8 s% }3 A- x% y. e" s( K! K
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
& L$ X' A- w- i' z# n$ A( ]http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
6 A+ O. \7 V3 X+ _$ U) w+ v2 k1 N下载完成后双击打开,一路Next即可安装完成。/ ~/ A/ l8 F* C
- l, x) y8 I, w$ s- t* j 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
9 N+ b+ c* D3 O, w% u
+ }( [4 w) b/ l: P2 `+ \#asp.net
" g/ { a+ j8 ^4 f5 \3 o- W& a$ ALoadModule aspdotnet_module "modules/mod_aspdotnet.so"' |+ L6 H, U7 R7 a; g' H
1 P' P" p3 F0 M
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
$ N7 ^7 D" g+ G/ V licx rem resources resx soap vb vbproj vsdisco webinfo ( f" j* ^- R/ ]- ~- y7 v
; d& F. ^$ _9 V0 D<IfModule mod_aspdotnet.cpp>+ G! v. T6 ]( G& l5 s2 f- ]
5 V$ `1 n; N& @5 S5 s! a% P # Mount the ASP.NET example application
- ~& E o+ A* }) M5 J# J* v' c' ^ AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
k! {9 s5 c. ]* m, t# h- s, R
. V% O; [5 T) M* V( ? # Map all requests for /active to the application files, h# K* G7 A" p$ }4 {- T
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"5 e: `2 M# k: p9 G3 V; \1 H7 k4 i
8 D; |5 P1 e" `3 P. G
# Allow asp.net scripts to be executed in the active example
) U' G0 j/ k/ H4 j4 T9 x! l- y& P# s <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
) s6 c3 h$ |7 j4 `/ w Options FollowSymlinks ExecCGI0 J$ `" ~7 p+ P/ L4 W
Order allow,deny8 h) V* s! W! v7 {& ~
Allow from all# v; @* a3 a8 h
DirectoryIndex Default.htm Default.aspx3 k* F' X# K; w# H
</Directory>. g; U4 y; _4 W/ ]& o
; h( w* A6 V, z/ g5 }5 x2 D0 @. D
# For all virtual ASP.NET webs, we need the aspnet_client files 7 S% \0 @0 t8 Y( H- q* l! D9 \
# to serve the client-side helper scripts.) d( r( O) m6 m2 J3 a/ k! d2 i
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \0 s+ G' S4 T& {6 C+ f8 J
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
4 {0 g) g7 c3 p" V( ~& C: m, R <Directory \3 V6 F3 K% a9 i+ t n4 U
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">2 ^+ H- B X! _: X: x
Options FollowSymlinks6 n% C5 z% Z9 p3 i4 `
Order allow,deny
8 o! q$ z' f0 g Allow from all
0 U5 A% V5 m# L/ D </Directory>5 l$ t3 }3 v5 V# V. @7 W9 r
6 k+ m3 k& Z- m# t
</IfModule>
) K1 g( x" y+ l" `8 [% _* v p. |4 x( f* u
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
) V; r$ y$ U; I( W$ R8 S: c y0 @现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
9 C m& ]1 C6 x! }
2 r0 H! @ q3 B; B# W 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|