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

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。+ t/ b, i) R" T4 Z" H
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。2 \" N7 d! ~4 Y5 M4 G- M% @& K) K3 G
下面就介绍让Apache支持ASP.NET的办法。
0 v* y& A  Y' o$ ^8 m0 W
9 b$ B: A$ J7 I0 t     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
) `4 R2 O% d+ f$ n. p% @# Z7 Z
" E4 d! M! g9 W" K( H# d. k5 ^     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:" S& ^$ [+ t: h( f2 y7 F/ P
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi- }+ ^2 L" x2 ~4 j: K
具体的安装过程请参阅其他文章,本文不再赘述。
1 c0 ]( C4 f. A) R  {
( R" _* V& L( R/ \1 ], Y     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
5 ]) S/ K& N4 U) Xhttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
. a/ }6 a3 C! g& [+ E$ O; R下载完成后双击打开,一路Next即可安装完成。
: D6 _( i( R  o+ N/ [
& V' f2 {; m3 y* x     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:% _. y9 h6 q1 m
8 l. z9 ]/ s& E$ ~9 j8 K
#asp.net
, N) a4 `- }; J8 ZLoadModule aspdotnet_module "modules/mod_aspdotnet.so"
7 o& X# R/ x! o1 D5 k( C
  ~( \$ h" L7 s1 T1 H* n  d) cAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
4 W7 f7 h$ u' `% s. T4 w# T6 {. V& u" Z            licx rem resources resx soap vb vbproj vsdisco webinfo
8 I% X5 {, }. G* f: _) ?/ W
* \7 K6 |7 |. w* p4 z9 F<IfModule mod_aspdotnet.cpp>5 \3 y) a5 T5 h0 I2 R4 Z
8 U: u5 z! E+ Z! j2 k0 T
  # Mount the ASP.NET example application9 F  s4 K' T# Z  H" A' F; b
  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
: ^; O, Z+ r& S/ u# j! ]
* x% m% g) ^. {9 A. b  # Map all requests for /active to the application files1 \  W- M; p7 z3 n6 M. q
  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
3 D* Z/ s* }4 O7 m1 p3 Q6 v% C6 r  w/ w
  # Allow asp.net scripts to be executed in the active example  G/ t0 @2 i# a
  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">+ C( f+ l7 Q" F/ A7 C( v' f0 ~
    Options FollowSymlinks ExecCGI
1 T- a; U6 p2 ~4 ?1 A8 Z% b    Order allow,deny! ^# n2 k, M( y- f+ c/ a/ d& f
    Allow from all( @" o+ v' j) h4 D$ Y; z3 ~, O3 _7 o
    DirectoryIndex Default.htm Default.aspx
8 B& E  j! }( m8 v  </Directory>2 |9 u* N2 a- Z- K4 p: t* l
$ h, u; W. S4 c
  # For all virtual ASP.NET webs, we need the aspnet_client files
  B5 A" t  l( T  # to serve the client-side helper scripts.
6 d; Y" W) `9 @4 n: T9 I  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \6 y! K( k) f9 {0 `3 y6 C/ m
      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
+ I2 ]* A) R9 f; S, H( q  <Directory \
/ T: h9 P% v' l$ N% _) Y      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
/ a6 j. k' o$ G/ L    Options FollowSymlinks  [" V; w9 _- H
    Order allow,deny
$ P. O8 E1 T$ |) i& Y  h8 \% Y    Allow from all
, s. H9 j; v; @  </Directory># g+ {# P( @7 i) M* i6 o: O  W2 j

: |$ O1 g0 _9 p</IfModule>
2 {! I; Y$ ?( f! V1 S  [# ^/ W, ]$ ]7 U4 R
     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
  ]5 }4 b* U" q! p现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。! n4 b% D6 F# Q2 {7 r5 h
- ?7 g' J7 M! M0 w3 j$ Q+ H  F- g. ]
     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-2-3 09:43 , Processed in 0.019263 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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