|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
7 b) S" J9 i$ Z3 Q! y$ U.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
0 j! ~0 w6 n/ y- h7 L+ [" ? U/ l( `下面就介绍让Apache支持ASP.NET的办法。
$ d. Y) B- i9 q, g$ t" v2 j' F% A
4 g" K+ ]# ^2 Y T1 f 首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
- g# c% I3 r8 a' [4 E, p
4 C. O# u4 n* q' R" j" R+ \ 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:& L+ ]7 n! a( O, ]
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
. u" `6 s6 |6 W具体的安装过程请参阅其他文章,本文不再赘述。4 r& L7 M% b1 r/ B% E" S
8 V6 ^/ `7 V2 I& Q
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:; ^1 ]; k. n9 i
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi$ d8 s4 b2 c; M, L0 _6 X
下载完成后双击打开,一路Next即可安装完成。) b( ?7 _4 j, x* _! D
& O+ `$ u9 f7 q; c+ E
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
. J" A o7 Y% t1 s1 a; ]+ Z+ ^1 d! H
#asp.net8 m( j( l4 b5 a$ r% n% v1 l% b
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
2 s) x' C9 L/ o Z7 e6 x$ Z3 m9 O" k* w9 ^) x7 o! A( @2 b
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
o5 x3 a/ B M9 M; b licx rem resources resx soap vb vbproj vsdisco webinfo
' c2 m9 v0 S% q5 Z4 ?' v. C+ g
<IfModule mod_aspdotnet.cpp>2 v- h- U. @, T, V9 Z
" ]# y& W5 E4 ?
# Mount the ASP.NET example application3 W1 c, u) y. V+ K2 I8 a7 M
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
& O9 [2 W7 U$ z5 x$ _3 @
2 T! p4 }; Q+ L* _- f8 O6 j # Map all requests for /active to the application files2 r: g% ^/ e& R! t6 G
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"5 {) ?8 x' h/ n
7 z$ V* f! t$ y9 g # Allow asp.net scripts to be executed in the active example
l+ G6 y# L# e) s4 G( r+ E <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
" l( a# j/ z7 C0 {; X( Z# p" l Options FollowSymlinks ExecCGI
4 V! @# _' }7 r: q/ f. Y3 T7 M: I Order allow,deny* [1 d' H2 T, }8 ]9 Q( b
Allow from all Q" i$ m- q! R7 z8 X
DirectoryIndex Default.htm Default.aspx
- N9 I$ Q' ~& y% i, k </Directory>
/ U) E4 n7 t+ H( Y
- f0 i$ V" c& T) Z% c; c# E* e # For all virtual ASP.NET webs, we need the aspnet_client files - w7 m% U I8 h1 P3 U, t* C
# to serve the client-side helper scripts.
$ r% G( Y; i2 x6 Y3 s AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
/ o4 S) k& i5 z "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"5 R! @0 h7 K" o) t9 g0 h( u
<Directory \
3 H$ L8 q2 E# z$ L$ a "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
( `. n8 I$ |# Z& j9 O* K- Y, \4 d Options FollowSymlinks3 X9 b$ E q. X- v z
Order allow,deny
: p9 j+ R |0 s$ p- ^. @, l Allow from all" s; @" j# Y8 H; ?4 F. p. j# C; v
</Directory>
* q L& S8 V% k. [& R$ c- k3 p: V+ e6 Q4 r d% ?
</IfModule>8 w* M/ {7 C C) o; Q) s% l: H
8 `8 E+ W/ Z7 B4 `. P% Y 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。. z f2 m5 d( Y) r1 ~* c; Z
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。1 f1 s8 r" x7 W1 c3 f5 Y
4 w+ k9 ] b3 r& x 由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|