找回密码
 注册
搜索
查看: 5728|回复: 0

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。; W, g: s# l+ q6 _0 w' ?3 F
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
5 K4 n  s7 I: Q, c& s下面就介绍让Apache支持ASP.NET的办法。$ h2 f5 o* i7 e* R2 q

4 X0 c0 [$ j- I# q- M# B1 @     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
; m* m" v; Q& ?" t8 O& V9 N( t0 J7 \% H+ {; y3 I0 n# }
     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
  h" u6 ^' a; X& g0 B7 k. Uhttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi3 K, t( ]- G( C- V
具体的安装过程请参阅其他文章,本文不再赘述。( E0 F$ y: _- V  L+ r0 z$ O

) J! s: i/ @! F; K+ Z     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
% ?! R- E# W0 N/ I$ chttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi2 }  G& b' e) t5 j; T) Z0 e
下载完成后双击打开,一路Next即可安装完成。& I. q4 Y; T- v7 f! Y, P
4 M, p  Q. n: o- n) [: Y9 i
     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:% |" z& J5 I6 G: Z; M; ]

! z7 o( M" B6 ]6 \  |( d#asp.net
6 X8 ~/ y9 Y! c% S0 u' k7 {LoadModule aspdotnet_module "modules/mod_aspdotnet.so"9 P: T7 L# U6 o* u/ K# j7 n
/ f. V) \- P" a* @7 e2 y
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
! J& K6 G6 K1 X1 k            licx rem resources resx soap vb vbproj vsdisco webinfo
; x9 q, v1 Y' f2 A  e% D. t8 J7 R. r, r1 A7 R! p/ y
<IfModule mod_aspdotnet.cpp>2 i- ?0 d/ Y& e* T' y' o) j
/ E* i. t+ H4 O4 w5 Q
  # Mount the ASP.NET example application
% V" ~( H: y& \" P* X0 w5 P2 @4 G  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"0 t0 I0 L4 t0 G! a& H% }
5 w% s# F. y! \- q# Z* @) e
  # Map all requests for /active to the application files
( E/ ?% g$ x* j+ h! [  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
. W2 i* f1 Z. b# G5 C7 d
& W% H4 O, H, s0 D  V  # Allow asp.net scripts to be executed in the active example4 O- i/ p5 O! \
  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">4 c9 W8 l: x- @6 s
    Options FollowSymlinks ExecCGI5 k( r! ]. o2 |7 h4 b/ ~
    Order allow,deny
8 b! d& E3 T5 \    Allow from all
' c# i; Y7 {3 E* U1 h7 d; L! ?    DirectoryIndex Default.htm Default.aspx
% [8 U2 ?# a$ y# i% c! f  </Directory>
: e2 y# y! l# v3 D  ~' |4 J) r. \) l6 ?& `5 u9 ]; M
  # For all virtual ASP.NET webs, we need the aspnet_client files 2 C8 Z2 E8 U& S) N
  # to serve the client-side helper scripts.- A. n' ~, B+ m  D. A7 b
  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
  o8 v- i" {* j0 }+ f      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
1 }3 k8 P' C+ d! s# p% {" L  <Directory \
( O0 n, z: G: d' u1 R      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">; h- ], t' Z7 o
    Options FollowSymlinks
' u9 P# W: j( q* V    Order allow,deny% X- N. Q- q* V4 W& o: m  q
    Allow from all
& |' a- s9 N) A; X3 |3 Z  </Directory>
3 h5 O, R% v. d- \+ l! [: _
# N. x2 w/ W! Y. a/ ?</IfModule>8 B+ j$ u1 V; _4 K, e8 M: @

' a- B0 o$ x. l' ^- Y* T' D     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
! M' h& S( s# a& o* Q* u现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
' V- ~1 i( X+ u1 s( M: X
* e6 {& g& Q* t& n     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|宁德市腾云网络科技有限公司 ( 闽ICP备2022007940号-5|闽公网安备 35092202000206号 )

GMT+8, 2026-1-21 20:06 , Processed in 0.019302 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表