|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。! U2 K; Z$ [: I2 {' e! |! |4 U
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。) G4 S! H- d. V0 c ]* A) {7 R& }6 E) R
下面就介绍让Apache支持ASP.NET的办法。* f+ G4 c- S9 ^
6 E8 }7 w. E/ K ^) T6 ^ 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
* y: P; v: k" n4 f- E( `' L
& @" p' W4 n" i/ w$ I 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
8 n. R- y9 }. \5 Shttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
6 J3 f- a T4 |6 D. _9 L* W具体的安装过程请参阅其他文章,本文不再赘述。
; {0 U7 Y8 M' m% |4 I
2 Y6 O. @( N9 _8 ~) f5 ]0 Q/ m 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
# X8 U2 k9 b# t6 Fhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi0 w! ?3 H# v, R4 U$ f
下载完成后双击打开,一路Next即可安装完成。
* h6 O6 t. v; d( E# D, c" P6 w/ x+ D; p m Y3 z
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
+ d: U8 J9 t5 a* ~7 a! Z9 `5 U9 Z, }' M6 @
#asp.net% Z+ C: b7 Q! }0 I) m
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"# p& Q* J$ H: X( j n f5 S$ b% X: U
5 Z; L5 i% B0 Q3 dAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
Y" T! U! X3 G/ ? licx rem resources resx soap vb vbproj vsdisco webinfo . Q2 C( Z9 i$ J( L5 F" G
8 P' R% O- }- m<IfModule mod_aspdotnet.cpp>
' D( p2 ^4 D ]( K a1 c& o' G
/ Z- @" V; A) W/ n0 c0 c # Mount the ASP.NET example application
; ~5 H. d9 H& {. I' C- P AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active": j8 k7 ^8 ^' a! C0 v
( a' F5 ?/ X, J, \4 R # Map all requests for /active to the application files
D3 q: R( |9 W6 }4 Q Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"* u( q6 Z1 h( J9 Y- Y+ ?2 K
5 ^2 p; J9 _) E # Allow asp.net scripts to be executed in the active example4 O1 E/ F6 o" [. T7 W3 P( B
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
+ I, o" X; ^2 a* }8 Z Options FollowSymlinks ExecCGI
' n% K& j- T0 y ]% m Order allow,deny
! _3 @9 y- q2 C2 V Allow from all
& o) L: Z# v, q# J DirectoryIndex Default.htm Default.aspx
' m t0 r# U/ N$ J# _- I5 Z* s </Directory>. \, K9 b0 u% q
1 x7 v3 X+ m% q& Q" E # For all virtual ASP.NET webs, we need the aspnet_client files 2 f, r: m4 w4 H; S. c, a$ `
# to serve the client-side helper scripts.
# W$ H' C% z0 E5 D I$ \0 L) c AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \+ f+ D& U/ g" w% L
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
, E. W. T q% i1 M <Directory \
5 ]$ s6 x4 [0 J5 Q0 a "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">* [% |" U b+ ~" j& g( h' w$ t
Options FollowSymlinks
, Q3 I% K; M& O1 X% }- l* |8 e Order allow,deny
, t5 R! p. N3 D( I7 C Allow from all
0 z0 |; ^0 w+ y: z( k9 y+ D4 | </Directory>4 T6 | F7 Y. {
" z" U; _9 k: Z& }$ ]# W" O/ T. p</IfModule>5 i. K+ w; U: e. ^
2 I$ Y5 B8 Q7 F* u* g, T7 f
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
0 D' E8 t5 `( H) k3 J% r) G现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
* f- f2 L+ j+ E e3 \% g- l! v8 ?1 b+ X! i# Y9 p8 L: g' O2 ?
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|