Apache是目前廣泛使用的一種網路伺服器程式,不僅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有許多網站放棄了IIS而轉向Apache。
.NET是微軟推出的功能強大的開發技術,其目標就是與Java抗衡。ASP.NET非常適合於中小企業的Web應用,其效能較ASP3.0有了極大的提高。
下面就介紹讓Apache支援ASP.NET的辦法。
首先,必須要有Windows環境和.NET Framework的支援。此外還建議安裝安裝.NET開發工具如.NET Framework SDK或者VisualStudio.NET。需要注意的是Windows的版本應為2000、2003和XP。Win9X系列不能安裝.NET Framework。
然後需要安裝Apache。應該使用Win32平台的Apache,版本2.0以上。推薦使用2.0.51版本。下載地址:
http://apache.freelamp.com/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi
具體的安裝過程請參閱其他文章,本文不再贅述。
下面要下載並安裝Apache環境下的ASP.NET模組。下載地址:
http://www.apache.org/dist/httpd/mod_aspdotnet/mod_aspdotnet-2.0.0.msi
下載完成後雙擊開啟,一路Next即可安裝完成。
為了便於管理,我們在htdocs目錄下建立一個active目錄,專門存放.aspx檔案。現在需要對httpd.conf檔案作一定配置,在檔案末尾添加:
#asp.net
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
AddHandler 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 /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
# Map all requests for /active to the application files
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/active"
# Allow asp.net scripts to be executed in the active example
<Directory "D:/Program Files/Apache Group/Apache2/htdocs/active">
Options FollowSymlinks ExecCGI
Order allow,deny
Allow from all
DirectoryIndex Default.htm Default.aspx
</Directory>
# For all virtual ASP.NET webs, we need the aspnet_client files