用 Apache 发布 ASP.NET 网站

时间:2023-03-09 06:28:47
用 Apache 发布 ASP.NET 网站

由于服务器需要发布 JSP 、PHP、ASP.NET 几种网站进行测试,Apache 肯定是支持 JSP  和 PHP 。鉴于 Apache 的开放精神 ,ASP.Net 应该也是支持的,于是乎 Google之。配置步骤如下:

1.下载 ASP.NET 解析模块(mod_aspdotnet )

下载地址:http://sourceforge.net/projects/mod-aspdotnet/ ,直接安装。在...\apache\modules目录下会出现一个名为 mod_aspdotnet.so 的模块。

2.配置 Apache 使其支持此模块

创建配置文件 mod_aspdotnet.conf, 保存在 ...\apache\conf 目录下,其内容如下:

  1. # ASP.NET Support
  2. LoadModule aspdotnet_module modules/mod_aspdotnet.so
  3. AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo
  4. <IfModule mod_aspdotnet.cpp>
  5. # Mount the ASP.NET example application
  6. AspNetMount /aspnet "f:/demo"
  7. # Map all requests for /active to the application files
  8. Alias /aspnet "f:/demo"
  9. # Allow asp.net scripts to be executed in the active example
  10. <Directory "f:/demo">
  11. Options FollowSymlinks ExecCGI
  12. Order allow,deny
  13. Allow from all
  14. DirectoryIndex index.aspx Default.aspx index.html
  15. </Directory>
  16. # For all virtual ASP.NET webs, we need the aspnet_client files
  17. # to serve the client-side helper scripts.
  18. AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
  19. <Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
  20. Options FollowSymlinks
  21. Order allow,deny
  22. Allow from all
  23. </Directory>
  24. </IfModule>

注意:下面两句不能换行,且网站本地路径中不能包含中文字符。

AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo

AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"

然后再 httpd.conf 文件末尾添加

  1. #mod_aspdotnet support
  2. Include conf/mod_aspdotnet.conf

最后重启 Apache 即可。

3. 测试

编写测试页default.aspx,放在“f:/demo” 目录下

输入测试页:http://localhost:8080/aspnet/default.aspx