|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
, K2 n0 C8 [; s- q# f.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
4 P! n$ T% }* q8 }% {下面就介绍让Apache支持ASP.NET的办法。8 W0 h$ V9 l# C7 y4 \$ w5 p- q
2 t" v$ O4 u7 h) O$ {/ l" n 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。* K' D- u+ P2 Z& O4 t- S0 {, ]
5 E% w' C) B/ B: R/ f) V: Y. d 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:6 Q/ `1 x4 h. \, [4 U# X
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
4 s# E0 E1 v+ B- [" x( F c' p具体的安装过程请参阅其他文章,本文不再赘述。
8 c! `3 }9 B0 g# Z# U, ~: {; P! T/ R# n d
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:( ^: Z) }% W4 G. w9 V
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi6 \: S; p# i, e- \
下载完成后双击打开,一路Next即可安装完成。
! O# x% a$ n# g8 Z) t! b o" f' c3 h9 R$ z4 W' \/ r5 @% n
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:1 b+ a% w! a+ L
: |& w$ V" `% b2 e# }% T#asp.net
4 a+ {$ `& d! i+ ~" ]1 ^LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
: k2 t/ V! Z% h! a+ G4 Y" ^2 Q1 V: l/ n0 X& o# f" W/ I2 h
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
/ }: N* u P5 x/ e9 n$ } licx rem resources resx soap vb vbproj vsdisco webinfo
9 {0 D& }- Z" L. c* y! K
! b+ l* W& Q* j<IfModule mod_aspdotnet.cpp>
2 B5 p+ ~% c, L4 a: E' H) m2 h; B- {! w; v/ U2 A5 l U% [
# Mount the ASP.NET example application
' l! I8 k5 h. {: Q5 p7 Z0 z! I6 X AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
8 w7 G' _2 x7 d; @2 D# r1 O5 S, N5 `5 Z8 ]6 i8 g% T
# Map all requests for /active to the application files2 w/ [- B7 a; h* |6 Y5 u% N
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"6 T2 V, d0 M; X: g
U4 N9 F* b( C0 ~ # Allow asp.net scripts to be executed in the active example
' {& M8 ?% A" [& w <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
3 O0 @5 H" X' R) J E, Z M9 k Options FollowSymlinks ExecCGI
* g0 y) l6 f: _- `% u Order allow,deny3 m2 u. I3 [9 U, b3 I6 M
Allow from all
/ P( U( a$ M$ f6 ?6 i. t# T DirectoryIndex Default.htm Default.aspx
. C; B: d) `1 D" K; r </Directory>5 L4 H; R- t2 \0 X1 `! ^$ q$ r
2 Q& c- m7 M8 j! p* o5 u: Z- r
# For all virtual ASP.NET webs, we need the aspnet_client files % M* N9 |/ l& b a& y
# to serve the client-side helper scripts.- P; V4 I1 {& d
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \2 ?* @, [8 {: `- e6 d( W" q
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"& r- K* [ \/ j6 i3 c5 p' i) y
<Directory \
8 g% g; ^6 l) a8 z* t2 Q4 F "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">( l3 w7 S/ `9 w6 F. |5 b
Options FollowSymlinks
" N* \" J0 S- L0 j4 A6 X Order allow,deny
4 `1 y# \8 |8 b9 n; O( q+ A t/ F Allow from all
1 N9 B+ V, }2 E/ H+ J </Directory>: n5 S0 x f3 s9 h1 G1 s0 {
1 a3 U; H1 k: O& R w( a+ M7 q</IfModule>
M* S% I: _- B) _
% S2 h% c7 v! ?6 d9 i7 p 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。7 M O8 z3 A% E! T
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
: u' y" V) G/ m- q3 V% q d. ]- z h& g I
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|