|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。' g4 f9 a" R# X
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
- N+ t* G, ?& G$ Y5 U& m9 j# [: A下面就介绍让Apache支持ASP.NET的办法。
w$ l9 W( u s3 [- ]; i# J+ a. R5 a/ t5 o& i
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
# M P, C& t+ D4 w0 a& F( a4 o/ N+ s3 @1 J! Y$ D! p1 R; n
然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:! M3 c# i( a$ N/ t
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
$ ]5 s: ?, i" _: ~9 M7 R具体的安装过程请参阅其他文章,本文不再赘述。
) g& [; A7 P4 z
2 U2 e: v3 S" \1 a 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
9 B6 o* X$ c# T' k5 s" |( Ehttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi5 L; T) {& F2 g4 p
下载完成后双击打开,一路Next即可安装完成。5 s1 |% E- B2 p* N, t
4 r7 S1 V3 i! A* ]' P+ W' i+ o 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:% F9 }) ]: W& L: D* g* Q7 v
" m" b; m7 H0 ?8 j
#asp.net. p; H0 m8 t7 k% [- c4 c2 d
LoadModule aspdotnet_module "modules/mod_aspdotnet.so" G2 T" M6 q) Y3 C2 s
& T: j& E2 R' s) E! F" Z0 e
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
+ S, k7 e3 {) L+ r; {# X5 L licx rem resources resx soap vb vbproj vsdisco webinfo 9 | W% U8 ~ L0 F) S4 F8 K
; A4 H3 C! X/ z3 C- o8 [! o
<IfModule mod_aspdotnet.cpp>* d) W/ O2 n/ f4 ` I) v
+ X" x% @+ i+ P. X g # Mount the ASP.NET example application& F' x( s1 N. h" \4 t* I; @
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
; J- J/ o# e) J U/ K' C( q# A! E0 T* p
# Map all requests for /active to the application files! p* B0 k, D- |4 J9 _, Z
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
$ d. o6 Z8 _5 R! ?2 B6 K- j$ O
8 F2 M+ }+ ^! N0 P # Allow asp.net scripts to be executed in the active example; m% m9 q/ N& t; r! M' X
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">5 [5 V% ], Q' Z3 [3 G
Options FollowSymlinks ExecCGI- [! e* X! U8 R0 r
Order allow,deny6 ^# a: X* {6 g3 R7 m' _
Allow from all" |7 g( v, s- p/ _% a2 z, j9 h% o) x4 ]
DirectoryIndex Default.htm Default.aspx3 G' Y7 H3 ~! I. X# Z
</Directory>* h- s5 m( b- d; w, q! y9 D
# N: ^2 F) S; g9 m4 b. C" Z9 f
# For all virtual ASP.NET webs, we need the aspnet_client files
) f l: n! i! y+ x1 D; S # to serve the client-side helper scripts.
5 Y' }& w: B- M! c W4 ~ AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \# x' p! s( x& A( m2 O6 @1 J
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
# @: w! Q+ Q9 T2 s6 @# ? <Directory \" r Y) @$ B& }! u, f- N6 _
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles"># j% w7 D/ ]+ f& Z! I
Options FollowSymlinks+ A" g2 o( E! s7 `0 J
Order allow,deny) x+ p, o; }$ S3 I0 f. s9 g
Allow from all. y% P6 p1 t J
</Directory>" V" }4 f" A F# s$ ~" f9 |
8 u+ f" F& | R& I7 ?2 ]
</IfModule>
6 J% {" R! \! h; K0 w0 w' \) b3 R! h! I& x8 Y! f }: Q- N
其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。4 \5 D) |1 R) [& H3 T- i* w- G
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。/ r/ M8 }) J( B& a; N
9 J4 A" s4 |9 N% f, G; y
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|