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以上。:http://apache.justdn.org/httpd/bina...,具體的安裝過程請參閱其他文章,本文不再贅述。
下面要下載並安裝Apache環境下的ASP.NET模組。:http://www.apache.org/dist/httpd/mo...下載完成後雙擊開啟,一路Next即可安裝完成。
為了便於管理,我們在htdocs目錄下建立一個asp目錄,專門存放.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
# Mount the ASP.NET example application
AspNetMount /active "D:/Program Files/Apache Group/Apache2/htdocs/asp"
# Map all requests for /active to the application files
Alias /active "D:/Program Files/Apache Group/Apache2/htdocs/asp"
# Allow asp.net scripts to be executed in the active example
Options FollowSymlinks ExecCGI
Order allow,deny
Allow from all
DirectoryIndex Default.htm Default.aspx
# 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"
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
Options FollowSymlinks
Order allow,deny
Allow from all
其中D:/Program Files/Apache Group/Apache2是Apache的安裝目錄,應根據實際情況更改。現在可以在asp目錄下放上ASP.NET探針。重啟Apache之後,即可體驗Apache下的ASP.NET了。
由於IIS和Apache下的ASP.NET都是運行在Common Language Runtime(CRL)的基礎上,因此Apache環境下的ASP.NET程式的運行速度不會比在IIS下慢。