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

让Apache支持ASP.NET

[复制链接]
发表于 2006-12-17 18:33:15 | 显示全部楼层 |阅读模式
Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS而转向Apache。
: b' f5 H9 P" {8 s( f" v4 f$ O.NET是微软推出的功能强大的开发技术,其目标就是与Java抗衡。ASP.NET非常适合于中小企业的Web应用,其性能较ASP3.0有了极大的提高。
6 l6 Z) ?9 z: w0 i) M) |% d下面就介绍让Apache支持ASP.NET的办法。8 T! ^$ ^- F1 M* U

" r# \+ Y% a6 h3 d  [* y     首先,必须要有Windows环境和.NET Framework的支持。此外还建议安装安装.NET开发工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本应为2000、2003和XP。Win9X系列不能安装.NET Framework。
' I  G( L1 Z) V" T) Y# t4 q; ~- S. h1 P. W5 t. m6 s& e
     然后需要安装Apache。应该使用Win32平台的Apache,版本2.0以上。推荐使用2.0.51版本。下载地址:1 u, @- I. [# h% D" g4 C9 v3 N2 q
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi1 J  ]  r( m3 O# E+ |9 E5 M% V
具体的安装过程请参阅其他文章,本文不再赘述。
3 E8 V, L0 F: Y2 z: j7 L& [4 \4 G
, |4 H. A& [& n     下面要下载并安装Apache环境下的ASP.NET模块。下载地址:5 j2 @3 d* K. v
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi, A  O* w+ q  {7 t2 v* u* Z' c9 J
下载完成后双击打开,一路Next即可安装完成。
7 ?0 ~9 y2 F* k: A
$ a6 h; G' B2 K/ C6 z     为了便于管理,我们在htdocs目录下新建一个active目录,专门存放.aspx文件。现在需要对httpd.conf文件作一定配置,在文件末尾添加:2 z3 g  |0 Q( q. e" ]
; g/ w) x1 ~! z% ]; ~
#asp.net) N( H$ f  S5 v% i5 V3 W
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
0 j1 I+ \' z1 Q; ?; |8 |7 j* G1 q) c# {. D
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
( D2 W1 D/ b, t4 a            licx rem resources resx soap vb vbproj vsdisco webinfo
. R, C* }8 H  H8 L7 a
% {) g+ I% P( F3 i: C<IfModule mod_aspdotnet.cpp>
0 P- a1 l( p) [
# E: f5 c7 I, b8 z: n! [  # Mount the ASP.NET example application
# {( |( Y4 l4 o2 A  e$ F' [0 N* P  AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
* p1 g6 n$ h7 F2 I3 S/ O  @2 `7 T( z% @- K  d' [2 T
  # Map all requests for /active to the application files
: w7 H! {; ~- }- d% _! w. o, U  Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
1 k8 K$ i. U# q$ P/ s5 b0 H. g9 G. W, a" `
  # Allow asp.net scripts to be executed in the active example
- P0 t+ n$ j3 ]9 c6 i  p, r/ U" [  <Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">4 I% `5 D. G, C% ?
    Options FollowSymlinks ExecCGI4 S. l7 x9 Z2 Q( T; b9 {
    Order allow,deny  w0 ]+ h7 T# e5 c0 V0 `) ?/ f
    Allow from all
' @+ r4 h7 ]( p/ G" w- F0 h5 k/ o    DirectoryIndex Default.htm Default.aspx9 a6 b1 d9 X( ?% J
  </Directory>$ [5 V2 u" x7 L8 s/ t

, B2 r1 \0 Y. f9 J  # For all virtual ASP.NET webs, we need the aspnet_client files 9 B) V6 [6 t- V6 y$ f
  # to serve the client-side helper scripts.
7 k# s  S8 d& L8 W1 c+ \+ G  AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \
- l" _. i# I' B8 ^      "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"  `- S! O$ w9 L) o
  <Directory \/ V: Z+ d4 I1 l4 @# [' \
      "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">' s4 v: `) |/ }1 }6 \
    Options FollowSymlinks! U" r$ @# Q1 s/ t: F2 m6 t
    Order allow,deny
( B2 k* H- i) u. L/ n    Allow from all
/ c$ t, t, M1 e1 f  </Directory>
2 c% n* N4 X7 l1 S/ g) V
4 v8 V9 f9 [1 A</IfModule>
9 @( Q8 F2 ]4 k3 ^- g9 y2 M- f" K. }4 ^1 U5 N
     其中D:/Program Files/Apache Group/Apache2是Apache的安装目录,应根据实际情况更改。
6 o* Z/ ^2 A% h) J现在可以在active目录下放上ASP.NET探针。重启Apache之后,即可体验Apache下的ASP.NET了。
: ^$ `7 j9 X  P  R: Z1 C- u% q+ E! P% D7 n8 Q' x9 }/ }
     由于IIS和Apache下的ASP.NET都是运行在Common Language Runtime(CRL)的基础上,因此Apache环境下的ASP.NET程序的运行速度不会比在IIS下慢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-1-16 20:27 , Processed in 0.018208 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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