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

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
! {* ^" N, x& ~+ P+ b.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。3 I2 [6 s5 U* t) W0 _6 R; u% W. ]/ x
下面就介绍让Apache支持ASP.NET的办法。3 q7 G3 q: j+ L: j% N

* ~2 [6 y) ?" \8 Y     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。) h$ ?/ m. D" d, q
  N2 m: K" |- |. j8 |3 K% U' ~4 z
     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:# T' y! {& z5 J: Q; J5 ?: W
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
# g' N. y6 `, \/ ^0 W7 j" Q具体的安装过程请参阅其他文章,本文不再赘述。
% ~5 ~. a! L; d! S9 k0 {: C! A5 f- A! ~, ?1 p( s) V
     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:; Y3 v  m9 G2 [# }
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi$ N+ t  M  F! u' h
下载完成后双击打开,一路Next即可安装完成。
% X" e: D+ e3 o' G4 X6 ?/ f& l$ h! u& E) m
     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
% M, z0 i5 L  W4 K6 d/ V+ e8 D( p% N4 h/ C0 d
#asp.net- w* C/ E3 K) q( o, T- S( V" Y6 [
LoadModule aspdotnet_module "modules/mod_aspdotnet.so". e; I2 ~, ]$ @- p2 M5 U

1 j3 @1 f0 a! s' mAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
0 w7 c* s. L$ q" r: H- c            licx rem resources resx soap vb vbproj vsdisco webinfo
" t$ w7 p/ ^! M/ O; f$ `9 @( K' c0 J
<IfModule mod_aspdotnet.cpp>/ R% p7 @, u2 S. r
" ^0 h5 L% `- U( E. U% e( X
  # Mount the ASP.NET example application# `( t' a4 b0 ]3 l
  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
& ~+ n4 u4 m7 t6 _' l- t
; E: X9 q4 D+ v# z/ E8 e  # Map all requests for /active to the application files
& ?4 x4 {/ U( o, `5 ]# Q1 s  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
3 n( G3 f, h2 Y% H2 Z# N- Q0 d+ U7 A2 G8 i! ^
  # Allow asp.net scripts to be executed in the active example
; Q( X( y. a7 Z  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">6 C" i: h; ^0 W; z. A' t: L3 O
    Options FollowSymlinks ExecCGI
* y! _5 ^  y! X& j- P) _3 M$ P    Order allow,deny
$ I# W+ Y6 y: v2 z+ B) \% u3 g    Allow from all$ n; ]- a+ ~' R/ s  k
    DirectoryIndex Default.htm Default.aspx
; M# f+ F" o- k  P$ P# p  </Directory>9 V' t4 J  {8 k  R

# N$ X# f3 A( @( m. v  u  # For all virtual ASP.NET webs, we need the aspnet_client files
5 z* f1 }3 v3 [- ~! q- @& [  # to serve the client-side helper scripts.- U  F2 K' u) Z5 @" |
  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \( H0 E2 Q, i1 u0 _2 n2 i' l* L% h) j
      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"' b0 o. t* W# u1 _
  <Directory \
8 e" M- @! J4 l5 f4 `6 s1 j) D- U      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">3 I3 Y) \  x" D' C& {3 T
    Options FollowSymlinks( \8 u+ p1 N9 U
    Order allow,deny
4 Z6 S+ U. X6 r' W- \  v    Allow from all( C. ]/ s1 z3 O$ T; x
  </Directory>3 m; E. Z* u, ~5 v, D* Q$ z

; E0 _! f3 o0 J9 ?1 t</IfModule>
# A# g" _* A( Z& K2 Z7 [" K, P+ x" k" p$ H+ W
     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。; @& J) U: O% K  x) r7 e
现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。, z+ \: J4 U" z( M* @$ p

* R1 S/ u% B5 y; m+ C1 n     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-18 14:31 , Processed in 0.017027 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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