用 Apache 发布 ASP.NET 网站

来源:互联网 发布:安卓client软件 编辑:程序博客网 时间:2024/06/02 01:02

由于服务器需要发布 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 目录下,其内容如下:

# ASP.NET SupportLoadModule aspdotnet_module modules/mod_aspdotnet.soAddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo <IfModule mod_aspdotnet.cpp>    # Mount the ASP.NET example application    AspNetMount /aspnet "f:/demo"    # Map all requests for /active to the application files    Alias /aspnet "f:/demo"    # Allow asp.net scripts to be executed in the active example    <Directory "f:/demo">        Options FollowSymlinks ExecCGI        Order allow,deny        Allow from all        DirectoryIndex index.aspx Default.aspx index.html    </Directory>    # For all virtual ASP.NET webs, we need the aspnet_client files    # to serve the client-side helper scripts.    AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) \"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"    <Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">        Options FollowSymlinks        Order allow,deny        Allow from all    </Directory></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 文件末尾添加

#mod_aspdotnet supportInclude conf/mod_aspdotnet.conf

最后重启 Apache 即可。

3. 测试

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

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

原创粉丝点击