|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。+ H' l7 V2 e& w! A- f9 g
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
4 B& k6 n3 p [" t3 i+ j下面就介绍让Apache支持ASP.NET的办法。& k$ ]7 k1 B# \- S' }& T
7 y- K$ u! T' f" k# t
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
; S: X3 x7 j! ]
9 k P( o0 L) F. e+ ? 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
7 t+ N# ] `; r( d6 F7 Z Y6 {7 }$ {# S: khttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
% I0 |2 z$ Q1 C$ C$ B1 y具体的安装过程请参阅其他文章,本文不再赘述。
5 e4 y* a/ _- g; T/ o& C3 A: ~
f T2 q$ E2 r 下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
7 c4 y* H% j1 i2 ]: C$ G( Dhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi! k0 [# ~6 C' g, P3 J9 T
下载完成后双击打开,一路Next即可安装完成。$ u0 @$ L0 ]) n4 @2 `
/ f+ }, E/ m& W) C 为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:: T8 `: Q7 B$ _( D; c
9 g: Q/ k1 {3 x8 l# c$ B#asp.net+ d2 N7 O; d9 ^; y5 X2 o% |
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"8 Z2 R# B4 ]2 L. n. }# Y2 \
) V& H' ~; s* P! z; f F. r
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
" h5 \. |) v* e, W2 ` licx rem resources resx soap vb vbproj vsdisco webinfo
7 @8 j; q1 B9 g
. F( o5 a: l7 b2 x) g<IfModule mod_aspdotnet.cpp>
, F& C8 B7 S( w" P& l& C6 q h' J: F f( |7 }& m) j. M
# Mount the ASP.NET example application1 p# j" I9 t, E( q
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
' T3 g3 \* N; L4 |! S% i
* H; @# z3 a! S6 [2 P # Map all requests for /active to the application files. @4 y3 [6 l5 n% r4 }
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
1 l7 ~9 u6 a% Y+ O/ d: A; H
+ x x T, j0 `! _+ J # Allow asp.net scripts to be executed in the active example
. x' u4 L, \2 Z& T* y <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
8 c* ~! ]6 R) \4 t4 m& A Options FollowSymlinks ExecCGI8 Q$ X$ A( x" { w/ V' ?) V
Order allow,deny' O: B- k$ f! N8 x& R- h1 }6 X* {
Allow from all
# q$ j1 ]/ [* ^; m DirectoryIndex Default.htm Default.aspx
3 ]/ W' V* P9 p% J5 V! g4 S </Directory>& e, y3 [* Q9 ~# ^1 `7 `
* c; N- {( Z$ H: x) ?, \; `" c
# For all virtual ASP.NET webs, we need the aspnet_client files
- N9 J* N' y4 S7 ], W: V # to serve the client-side helper scripts.
; y n' A+ t! N5 u2 b* R AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
4 u2 g$ M5 B) W3 L$ }6 \ "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
& ^4 h' W/ \/ Q$ @3 G% L4 v <Directory \& {9 |+ r) e8 d; j# i
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">7 x) K. a7 p+ O% B3 A7 t# V- j8 I3 \
Options FollowSymlinks( l& ]7 U+ d# P! t2 |( Z& R2 n1 ]
Order allow,deny' u. C# G7 c5 A0 v+ E+ _0 }. ?% E
Allow from all
, Q" Y& a8 Q* ~# C8 ^ </Directory>( g' I4 I1 p8 [! q
, P; }; S( d' B1 x2 X
</IfModule>) \6 X) x; ^# @6 ]. v
& T, g- J; x3 v) q! D. ]; e 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
/ t+ [8 L9 y) q2 H5 M% F! M: {4 p4 e; ?现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
, o* C! C' \+ @; Y5 j
9 b6 w3 L9 g8 {3 V% K: d" n 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|