|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
1 e8 N4 d( }1 z3 N- k1 _# h.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。; K2 ^6 d8 g$ Q0 z
下面就介绍让Apache支持ASP.NET的办法。
. Y; Y$ W5 `% V1 p) M) [
4 k( d; ^! X, A" s/ H 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
3 h8 m) H2 M1 g8 O' l0 X! w0 c- W! Z* f7 n9 C& E
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
3 h3 N/ Q8 C3 o; n6 c$ Rhttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
% X+ N. M" @# T6 {8 Y0 y- V具体的安装过程请参阅其他文章,本文不再赘述。( N# r8 p! @, @# B
8 a/ o* A) i- m4 h$ w9 m& E 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:: {# [; I8 a. M, i3 V0 o2 L
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi* {, g! G9 |0 [+ ~0 a& U
下载完成后双击打开,一路Next即可安装完成。
( t: `7 L9 P. N _) L, d0 @
. X" e) _6 `: w! d P! Z X+ H 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
; `$ ]. n& g9 t
$ n. l- @ r' s3 _. c0 u#asp.net' r( g+ n. B( B3 u& l. o* L
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
$ g& G) R2 P9 U7 n3 b
' z# g. S+ L3 r4 a8 j( _AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
+ W* X* [0 I8 n2 Z1 Y licx rem resources resx soap vb vbproj vsdisco webinfo
/ {* ~1 c+ M3 a; F4 {0 s
8 {4 y; P8 I5 ?" I2 f& q4 r4 x, O<IfModule mod_aspdotnet.cpp>
1 a& U5 f& l E' `
1 n- d) T$ m6 W: a t, } # Mount the ASP.NET example application
% [& {+ M% B. u6 E3 m9 ] AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"( l% X1 q+ O- c: K
. O. ~: H" e1 v6 m # Map all requests for /active to the application files0 E: ]; p3 U2 I6 Q( Q9 o2 X
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
8 K5 \% Z( ^& d6 W9 i" k" Y4 w
' t( `1 }3 R! T/ o- O; g # Allow asp.net scripts to be executed in the active example
! x6 l5 Z1 \8 x <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">" a% H* O# w7 E" L6 T2 D. j- u7 b' U
Options FollowSymlinks ExecCGI
+ F; B( G7 F3 \& I9 \6 i Order allow,deny
2 B6 ?/ @5 d9 w' Z7 ^9 X Allow from all9 ~8 N6 V: m; Q! G, s" P5 Y
DirectoryIndex Default.htm Default.aspx0 R W ?( w+ I9 m
</Directory>
* W8 `" R2 X& {& g3 v$ \
: L* R1 j) u+ x6 l& g # For all virtual ASP.NET webs, we need the aspnet_client files 4 ]' C i; m" Y9 j& l
# to serve the client-side helper scripts.) v0 N* o1 ]% m5 D
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \" q" K1 f3 G& i6 m
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
3 f) m" T- D" E2 { <Directory \
9 Y0 _& z7 @6 `' Q5 Q8 I9 Q: D "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
1 g4 h- F! i J" P1 ? Options FollowSymlinks
7 v" n. j) \ E' } Order allow,deny# W4 g# ~) y! L- x+ z! y& ?
Allow from all
# g/ o3 E+ U, s Q; A3 Y# E </Directory>
! Y2 Q1 ?0 o- b% z: X8 o3 L, ?8 Z% p% a9 p( D6 @
</IfModule>
% R. A5 o- T6 c/ j8 \+ ]
! r/ {+ w- V+ K8 M3 l( L9 M( i 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
$ d& p" T+ O% p现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
! |9 a; g% R0 a& L* T; U8 w6 u! C
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|