|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
$ v& s! w3 H! s! S.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
% _' d9 j; {& e0 Q下面就介绍让Apache支持ASP.NET的办法。
6 g' f& K: y4 J/ m, A5 K2 x2 q- y$ ~$ w+ `* K0 D& V- ]
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
: z3 F# @1 a3 b' k2 O% Q/ I6 b- G: u j! I
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:: U# ^+ G! B4 ?) y
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
0 y( G" m+ K7 u% S; z5 h" ~% e具体的安装过程请参阅其他文章,本文不再赘述。
# U5 Y. k8 B/ K% u
* \% ?. c9 @* M7 L 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
^3 e* ]- k; \! c) uhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi' x0 [! Z3 P; ^' a' H- z
下载完成后双击打开,一路Next即可安装完成。
4 p/ r$ D+ N! Z* b. ~- H) H4 D9 r& x$ Y; T1 R. s
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:4 e& ~9 ?0 {4 k! [( |
4 O! j# A+ M7 l* f1 z
#asp.net8 S" P# W1 ]0 T3 I; X
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"" j: i* V4 _/ X0 q
" x* b- C4 T) F- V4 B3 M# ]1 s+ RAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
8 R- {' E+ N1 Y6 A licx rem resources resx soap vb vbproj vsdisco webinfo
2 T/ p7 h% d/ s9 h% v6 n( ~; Z4 C. d5 {6 U: m
<IfModule mod_aspdotnet.cpp>
( L5 D/ F! k' D
+ s7 K- g1 [6 v7 D/ X7 B # Mount the ASP.NET example application
: h) T( f/ A9 G* U# R) C: S) K. j* K* i AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
7 c$ E# `; e$ t& ~0 _6 b0 g; F1 _$ r" l* i# A3 R1 K
# Map all requests for /active to the application files/ V6 @% r, b! E- R# g
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"! m1 ^; u% M- x+ r1 j+ A, h
) n, ]4 ^2 m& E8 c: }' `1 x, Y # Allow asp.net scripts to be executed in the active example$ K c7 v: F' J% t: i9 U2 @
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">$ Q& F, e! W& t% r' w" _
Options FollowSymlinks ExecCGI
. m& N1 Q, T% b5 D. { Order allow,deny
4 M& f% e5 K3 A Allow from all
- y0 Z) `( P: y* Z w0 N DirectoryIndex Default.htm Default.aspx
7 X; A# e; A( J2 g+ [: s </Directory>
( X5 }/ I0 F( v! S3 j
! U9 a' J5 B# T7 f0 ] # For all virtual ASP.NET webs, we need the aspnet_client files ' I) Y/ x N( y3 H! `% V1 F
# to serve the client-side helper scripts.; ^# w+ L# b/ a2 g4 o
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \* c* O$ }+ t: g7 W. {. s* w+ \
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
0 {3 n5 D/ U, S. h% r <Directory \7 ~4 R2 P1 D0 j" U
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">1 Q4 A) l; f3 l
Options FollowSymlinks7 M/ m* a; M6 R0 K
Order allow,deny
2 Q0 N2 H. j: A1 V- ^ Allow from all
# D1 j9 X) a! r4 i+ T9 v! y </Directory>
& T5 Z$ ~0 Q0 N4 i8 T# Y! _3 u! q5 l3 Q, x- Z
</IfModule>( t- y# b' \. [" I4 W& [
; r/ D6 O: K$ c8 L: k+ H7 M
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
" m8 d5 S! z2 e: M! j* g现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。! J6 p# V1 }; a* Q9 X R( x: k
" c9 T9 k. w& ^6 `
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|