|
|
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。' ] Y0 ~; A G
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
+ [" r; E# }$ r3 v* ~: r下面就介绍让Apache支持ASP.NET的办法。& x5 H) _4 m, G& \/ j# D c9 b" _
3 ?9 c) Z4 ^1 Y
首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
! ^4 R. h# V# D y5 L
+ `0 o6 j# z. n" [ 然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:) M0 d, {- `; \7 {
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi" a9 i6 S( W! M3 m' y! \( x% b
具体的安装过程请参阅其他文章,本文不再赘述。
4 o. x8 _& E/ n$ L) W3 U: X: v; a7 q! i' J# |. |
下面要下载并安装Apache环境下的ASP.NET模块。下载地址:* ?; V4 ` ]; O+ K& V) R
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
1 ]9 m7 H$ s, a8 F4 V U% F L4 Z% V下载完成后双击打开,一路Next即可安装完成。
0 d! g4 E' N/ z% m; J# l6 g! U3 _. w. _& U2 w% G9 i( }
为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:; Y& e/ `/ t( K4 t0 a
/ q6 l0 J" n' g
#asp.net
) f, D8 W: I9 u! x, E- Y( VLoadModule aspdotnet_module "modules/mod_aspdotnet.so"
' }8 }, V, r9 g3 p7 f" V% d. R3 E! y- ]
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
8 a) x) {8 Y) @" l licx rem resources resx soap vb vbproj vsdisco webinfo 5 Z# l5 G8 T2 }, s% t O7 E
& b. \) m& Z5 A0 j3 Y
<IfModule mod_aspdotnet.cpp>
' e+ \4 i7 a3 G6 f5 P5 o7 J8 e+ y
( ]$ j' d5 W8 m" | # Mount the ASP.NET example application
. ^, k2 x+ V- {* ?+ W' _/ d AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"9 G+ a/ `# M1 M' W
( L" j' |# y: ?
# Map all requests for /active to the application files
# J G/ @3 }3 ]4 T0 g* V7 z* r Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
6 L- l. Y C) l* }% q2 H: w3 o' M8 {1 g1 K* j0 u2 x
# Allow asp.net scripts to be executed in the active example' }" g$ K& k1 `1 a. B _
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">, N" l2 D" C: u8 W2 z# N$ s1 j
Options FollowSymlinks ExecCGI
( \( l. k7 x# f x3 O ?$ I Order allow,deny) G, ^6 A! [2 V/ u3 V) Z
Allow from all
0 ^+ i, [ z: g; I* y) s3 c" [ DirectoryIndex Default.htm Default.aspx
) Z7 ?- d2 h7 l6 |5 g% g: D </Directory>6 v+ A7 R" E# l0 x7 ?: r2 ^; H
. T& N8 M4 F2 ^' _, [ # For all virtual ASP.NET webs, we need the aspnet_client files
6 K0 P4 c5 z8 V- x# o # to serve the client-side helper scripts.
; E7 K4 f: B+ e$ }7 T d$ a0 A AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
7 Z$ Q% z' A0 a4 E, g: m6 |; M- u "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
% j) A4 g3 y% |4 Z3 | <Directory \
3 P5 c/ U4 B5 c1 O "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
9 G! r5 s+ W' s: | Options FollowSymlinks
% ?) K" s3 m B9 _5 p Order allow,deny
0 d6 W% B$ i2 Q1 A& C* z0 C: w5 |8 A Allow from all
K$ R; h; Y' N. P! F+ Z </Directory>4 Q5 ?) a' P- s& T% _/ D
+ S) D0 L7 u1 g2 h$ U6 Z. {
</IfModule>, h2 o1 z$ o# W4 q! @8 I- s
/ v/ m6 l' T, a2 C7 k1 e/ N 其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
% w( }4 p s0 ]; B: m) a, }现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。& X. p# H! l3 g, g# E0 F
1 k- s; K" l( V3 x5 N6 d
由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。 |
|