|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
* C# K. ?. D d! U/ C4 Q) A.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。" E- ^% W4 G! T/ c3 u
下面就介绍让Apache支持ASP.NET的办法。* T9 L2 G$ T# f. z
; T; x1 P& E1 A7 h 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
, B& ^. B# z, ?4 O( [2 l8 e8 c/ [" C! B1 b1 A3 E' _
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:" B6 r' i! ~9 Y }5 K+ D0 K
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
" N5 ^2 x: ^ |3 _& _具体的安装过程请参阅其他文章,本文不再赘述。
9 _# I0 N+ t/ J+ g; O& _0 `+ q! v- s' K9 T6 G, w
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
: O ~6 X* w: [! J/ lhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
% O; ?# t3 U2 l下载完成后双击打开,一路Next即可安装完成。7 a+ G# v- m$ s0 ]
9 k. s6 M, a' K' {( ^ 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
' f6 K* s8 y* p- @6 E! F) u: d: r; u* f. N8 }" Z' n# {% t
#asp.net
* h3 J: K8 u9 r- q9 n8 l5 i- L( e, zLoadModule aspdotnet_module "modules/mod_aspdotnet.so"& G4 Q7 y5 U5 }+ j: ~& f4 a
a+ o1 f0 T- K# g8 Q( C2 z% L
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \( n; t7 y, l$ ^$ Q" n
licx rem resources resx soap vb vbproj vsdisco webinfo
, }5 W+ V* H' h# U8 J
8 \: P9 H5 q2 p7 \$ j<IfModule mod_aspdotnet.cpp>$ s% U& g' r0 m3 t
9 m8 }" E1 E$ `; q
# Mount the ASP.NET example application
9 r F# V N* V! ~, |" _7 W AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"+ X; D& |$ ]& v: v& ]3 O
8 `, k9 F' Z I% x; E+ _ # Map all requests for /active to the application files
) p1 b$ Z3 |. ~8 x; c Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
: _5 n" s2 Q3 h& |& }8 p% J0 m `6 j- J
0 E& n/ D8 A+ A4 [+ ^ Z5 O* { f! } # Allow asp.net scripts to be executed in the active example6 h* ~: @ v; ^4 M; e/ p
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">: f5 b8 g- Q2 s/ M- g$ k
Options FollowSymlinks ExecCGI ]* g3 o: `9 J% S" U6 S5 {
Order allow,deny
! J z; h0 d% Q4 h8 C; Z Allow from all
5 n8 U1 c9 G/ m# g! c DirectoryIndex Default.htm Default.aspx6 @; A4 h: @) w% Q, \4 s
</Directory>
0 p* _2 g. ?8 f% \. }% H
H% x0 p2 ?2 J+ n4 V # For all virtual ASP.NET webs, we need the aspnet_client files
% X8 ]4 A3 E* T3 c5 f7 m6 J # to serve the client-side helper scripts.
4 n. Q7 e% n, }* l& D AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \9 Q' I( v* e. x: q% ~
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
6 G, J8 g* V* E% I" y <Directory \
" O# e* d' T0 Z5 s( o$ m "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
+ K1 Q3 a, s" { m Options FollowSymlinks
9 h7 a3 q# W" _: Y" ? Order allow,deny
9 A/ I5 F- K) \ Allow from all0 \- k: R8 I8 P* R2 c6 @
</Directory>
0 B9 ~( v) P4 T- E: a* C# ?- D# R9 _0 H' n
</IfModule>
1 m! i6 d/ W8 H& X
& C$ b' o! R( S: Z/ T/ L0 _. h 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。" U4 e4 U& Z- m$ I$ V% y4 x/ h
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。3 q7 J9 ^# D# j8 O. I
( g' f1 C& o3 ~3 g# O8 `' O; H
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|