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

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。0 M6 d" X5 ^# x5 }5 G; o7 D
.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。# _. R+ d: U) a- g: Q
下面就介绍让Apache支持ASP.NET的办法。! ]3 r8 {1 q+ K4 R% l% r: n- O
; F3 F- V( p1 n% O7 v5 P) m
     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
6 e, f# h% \- k) `! B
  N/ g( O5 j2 t     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:
% _% w- t5 O+ F$ R9 ~8 v: }. Zhttp://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
1 q- b6 I5 c+ M3 d8 R" x具体的安装过程请参阅其他文章,本文不再赘述。% i& s6 W. h  i3 F0 ~7 Q4 W2 s% D: @) M

# `* S/ }+ A; h& L     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:
9 M1 E: n/ l* _! D* s- T$ Y3 Ihttp://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi) b( \0 q6 z2 V8 n! w+ f
下载完成后双击打开,一路Next即可安装完成。
& C$ A6 ?( d/ I6 ~% v* b8 B( M. W$ b- n
6 @: f: x. K6 ~: ^! z* m     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:
3 G* f9 q. d7 u
$ b, X. U% [+ P, w$ o# w' d8 J8 V& Z0 ]; [#asp.net+ I# a$ N$ k! |; s
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"- a3 V* x! g* g5 i& B
/ Y0 g0 g' X3 a- p
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \3 l# S+ I7 ^4 I
            licx rem resources resx soap vb vbproj vsdisco webinfo 6 ?1 K- U# q* Y3 {( p' L4 x

  l8 r. A/ i. U<IfModule mod_aspdotnet.cpp>! U+ l; ~. A9 q( j% X5 N$ p; {

. m1 Z9 P' j9 c. t6 P6 N4 V  # Mount the ASP.NET example application" E/ v) Q3 ?8 q/ Z$ M/ b8 r- @
  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"3 D/ t/ v& t# t4 H2 H; N% N% \
) }) c4 m, [" H0 T$ K/ W7 X
  # Map all requests for /active to the application files
1 X% h# K! Z) Q  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"7 f# ^+ G5 n0 y3 w3 K

, |( ]8 T8 t( @- ~4 B% }3 b  # Allow asp.net scripts to be executed in the active example
0 {: N7 ^" |5 E& M! Q  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
% s& f- ?  {4 b( g# _    Options FollowSymlinks ExecCGI
9 p9 D! e& z. n: b; p' c7 f& ^; d5 g    Order allow,deny) N/ J, I* g/ m
    Allow from all
4 U9 g; p- Q8 f* Q6 H  s( v    DirectoryIndex Default.htm Default.aspx
1 L- d9 r% b$ v, o8 ], ?# U: P  </Directory>
- G4 @3 l1 C; w+ m6 w, i2 X! @  N
0 s* e/ l+ ?6 _; J  # For all virtual ASP.NET webs, we need the aspnet_client files
% z2 ~9 b# p1 l7 @  # to serve the client-side helper scripts.
" B' Q$ z, [# e/ v- u- W. U5 w  f- {; i  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
; A. I; X( ~7 H* n4 L5 M. G3 F  j      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
+ e! D+ U) |/ x  F: Q  p* y) }3 O  <Directory \
6 x- s  J- c( a* M1 }      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">/ f5 @, W0 }: ]
    Options FollowSymlinks/ Q& f) A6 Q8 s' r: T
    Order allow,deny* \$ f: ?* ~; L* z% Y
    Allow from all0 r; D) R6 l) R" b) @) F
  </Directory>
% S- C; ^1 X8 L. C* m3 A/ O, M3 r
; l& G% S( w2 D% w; u3 _8 Q</IfModule>& e1 M8 V5 F1 B, @; k: J6 E
: y9 K! H7 D/ S9 E2 ]) U
     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
1 b) y4 R# ^" z4 ^! ]现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。& d& }+ l7 E$ X9 q" m0 B

, `$ ?1 ?7 x0 H& A% t% O     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-2-4 12:07 , Processed in 0.020426 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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