|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
/ A3 _ f4 w+ ?2 Z. z$ `# J+ L4 m.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。8 c" l* N. ?1 a) f5 j; I, [1 ~
下面就介绍让Apache支持ASP.NET的办法。1 u5 N/ z# U7 G4 q' v0 T5 r
( K3 v% d A# P1 R( ] 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
3 e) g$ Y6 X, f- E3 U7 R$ s; \/ F n2 k. b: D0 C$ z
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:" Z6 H) t& T( `7 D- {- Z, i T0 r
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
7 q% k8 p+ ^0 b7 r0 E& A: m具体的安装过程请参阅其他文章,本文不再赘述。
% r9 t4 e6 z# s+ B1 M8 k
a9 O/ r- T" K: h1 Z1 m 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:$ C5 b- N L3 ]* |
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
- M3 S: V' w) }% x3 L下载完成后双击打开,一路Next即可安装完成。- i5 M6 J$ a5 g- m9 h" K
5 P8 S# ~# k6 g% o 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
2 V4 `; z3 G& w) f/ a& i
) @' ~" M9 q7 s6 L6 P3 F( h; _#asp.net
2 e$ A$ M$ m" ALoadModule aspdotnet_module "modules/mod_aspdotnet.so"
$ G( V2 m: C6 J( g7 _5 \: ^
' F& c. c/ E+ x! m, rAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
3 A8 [) `2 _; c$ B& J# J f licx rem resources resx soap vb vbproj vsdisco webinfo " T5 o9 j" y, ]5 ?; U
+ t9 ?' D$ s9 m0 f$ g9 p6 f0 \<IfModule mod_aspdotnet.cpp>
7 r4 f/ ?* D" Z. l2 p7 r0 V4 Z% h( r# n5 i; H! h& x+ C' Q$ O( c
# Mount the ASP.NET example application
. ^; ? Y5 G- R1 y F' ~% m& h AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"8 K: `. x R9 I' a
) h4 T/ Y" X! ^! j2 L
# Map all requests for /active to the application files
5 Q3 o: {' c' Q* \% c1 J# W! ^/ ~ Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"& X8 [3 a& C" M O) w% u+ Z
1 p' B& l9 h N. ~! R
# Allow asp.net scripts to be executed in the active example
+ l6 Y( [4 ]; f+ C1 y* Q8 C5 | <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
- M+ K* _( n: B, r8 l( z, H8 R Options FollowSymlinks ExecCGI7 s. t7 |% ]0 e, } C. r$ W
Order allow,deny4 F0 b& u2 D P \" `9 x+ S& s
Allow from all7 v; ?+ A* i+ a) j3 R6 D0 [
DirectoryIndex Default.htm Default.aspx% }" H8 Z: d& j3 ~$ | @" n' K2 A
</Directory>/ G- F$ N6 ~7 y
, @0 V$ C2 j2 I* o' M6 S1 s! \4 J # For all virtual ASP.NET webs, we need the aspnet_client files * S- j0 I2 t/ S8 O5 ^* J. X, f% y& R
# to serve the client-side helper scripts.& P$ F$ K& a# u0 Q! C: N' _
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \# p9 }1 ?$ B) ?/ b
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
- l( \: g$ w$ O* O6 T <Directory \% B* Z; R7 G5 J; ~ k
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">) b9 q4 Y1 r- R7 e! {: z
Options FollowSymlinks
9 ~. q- _+ F6 l! F1 c, v% ~6 I+ r6 j Order allow,deny
; Z6 N X4 g& | Allow from all! G7 b$ p) k0 ~8 T
</Directory>
9 W$ d- R2 w$ J# r7 h
# F0 W" A3 G P7 |; A* {</IfModule>: o: f) [. K( k
5 ]; |0 n- _$ ^1 s/ ~3 D9 d
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。' P. x. U O7 _7 i1 Y t0 i# ^/ {
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
" o. U1 H; ^( X1 o
3 a$ U1 Y2 y5 J, ^2 | 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|