|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。0 f+ Z( I! f5 f( v
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。* Q" O2 W; r% i
下面就介绍让Apache支持ASP.NET的办法。
[; |% [) ]4 P6 i- M
; N9 @$ \: ?4 \' |. V; y$ d# D6 y 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
' {* W7 t4 @& [+ ^" Y! z0 M& `
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
/ j/ G; H- Z5 _& _. vhttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
/ F3 S* ~ R! t3 z k5 |# `( M具体的安装过程请参阅其他文章,本文不再赘述。
/ f; \/ |7 @% R* j# Z2 ?2 |7 U: E* ^& o; h# P; Y& Y5 ^
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:6 C' r' g) Z7 V& u# ~
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi( Y& U+ Q# _! q* a" w! \+ D% v9 e
下载完成后双击打开,一路Next即可安装完成。2 z Z% m$ {- b$ U
1 V3 U7 M" W1 f
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
7 v- R7 T3 G1 g) {6 E. q$ Q. p! d: y( g
#asp.net
1 Q0 J' |# @1 s q+ ^5 \! g9 FLoadModule aspdotnet_module "modules/mod_aspdotnet.so") P/ f8 }& Y% m8 q
) v) a# t, f% R" j: D V0 mAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \" e2 u0 c+ j% o1 S. v- |9 Q
licx rem resources resx soap vb vbproj vsdisco webinfo ' E" b' B/ H+ c" _- U% h
6 c7 c5 d/ G8 n* S3 @- a1 G
<IfModule mod_aspdotnet.cpp>2 ^! }- v, r6 T& ?8 s
; `* G4 n5 \- J' H/ F' h # Mount the ASP.NET example application1 `1 o4 F0 F y. W9 n4 E! u- W
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
6 _* X" F& n* j8 C3 s" s! m7 j
3 a s! k3 M/ j+ ^% r # Map all requests for /active to the application files9 w' X) ]6 M. u) M
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
w; x2 b: P& l7 v$ v' P/ S/ n2 h5 [$ ?) h
# Allow asp.net scripts to be executed in the active example8 Y0 T% p/ t! J6 J# f2 B# }6 L
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
. z9 L0 F& z4 S9 {3 n Options FollowSymlinks ExecCGI
" a0 e: e) o" R; v Order allow,deny
3 ~( U! j% f5 K) p4 [ Allow from all" K [! k2 S" x5 e$ Z
DirectoryIndex Default.htm Default.aspx, {2 L7 y. R$ h$ Q, Z2 O: ~
</Directory>
- u, ~" S8 V0 y* p8 F$ V- L% [1 h! \9 r2 y @4 ~- ~# Q; q
# For all virtual ASP.NET webs, we need the aspnet_client files
! d! c4 _' N/ O% t* d$ e # to serve the client-side helper scripts.8 E6 y. \1 C0 Y* l' b1 C
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
4 l- V* {" p1 @5 f "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
! V$ S+ ^8 l1 v$ u9 U2 C <Directory \
8 b* n! Q3 A c) s4 Y* y "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
h: F. r0 _8 T0 Q1 l8 X; W Options FollowSymlinks
- M6 }. g) Y) ?$ Z0 P1 g7 {* a5 p# C. O Order allow,deny2 ^, c# K$ S9 w: q: V* M
Allow from all
7 b4 u: P8 J3 u/ `/ i </Directory>
! l/ t8 p8 j' i( b' g# {3 z& D5 f1 l# n9 L8 M2 ~# |% @2 j3 K
</IfModule># E S" \) v5 a1 x2 E2 Q% z5 V6 j
" @" G" W% ^& q 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
$ H$ k7 s: O; q现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
1 @: B) u3 g" W0 n$ b
" M! v2 o! ?0 {! c/ @8 l9 v 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|