???
ヘッダーイメージ 本文へジャンプ
日記

2015年04月15日 20時32分
Windows上のApcheでASP.NETを動かす
ちょっと興味があって、Apache で ASP.NET を動かして見ました
OS は Windows なんで、そのままIIS使う方が良いんでしょうが・・・

Windows上の Apache で ASP.NET を動かすには mod_aspdotnet を入れれば良いようです
Linux上から呼ぶ場合は、それ以前に .Net FrameWork 互換の MONO とかいうのを入ればいけるみたいですが、今やりたいのは Windows上なんで、既に入ってるので、mod_aspdotnet だけ探します

このモジュール、どうやら最初は Apache プロジェクトで作られたようですが、現在では
https://sourceforge.jp/projects/sfnet_mod-aspdotnet/ で管理されているようです
しかも 2007 年で更新が止まってます・・・
やっぱり、IIS 使えって事ですかね・・・

とりあえず、最新版の mod_aspdotnet-2.2.0.2006-setup-r2.msi をダウンロードしました

Apache の最新は、現状2.4.12 まで行ってて64ビットもあるようですが
mod_aspdotnet が Apache2.2 の 32ビット版のモジュールのようですので、対象のサーバーをダウンロードします

私は ここ から httpd-2.2.29-win32-ssl_0.9.8.zip をダウンロードしました

で、適当なフォルダーに展開して、conf/httpd.conf の中の 「c:/Apache2」の部分を、展開したパスに置き換えた後、mod_aspdotnet-2.2.0.2006-setup-r2.msi を実行
実行すると、どのパスの Apache にインストールするか聞かれるので、正しく指定
(たぶん、mod_aspdotnet.so を modules フォルダーの中にコピーするだけ)

で conf/extra フォルダーの中に httpd-aspdotnet.conf の名前でファイルを作成し

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 /asp application
  AspNetMount /YYY "c:/XXX/YYY"
  #/asp is the alias name for asp.net to execute
  Alias /YYY "c:/XXX/YYY"
  # Allow asp.net scripts to be executed in the /asp example
  <Directory "c:/XXX/YYY">
    AspNet Files Virtual
    Options FollowSymlinks ExecCGI
    Order allow,deny
    Allow from all
    DirectoryIndex index.htm index.aspx
    #default the index page to .htm and .aspx
  </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>
※/YYYはURL(仮想ディレクトリ?)、/YYY/XXX は物理ディレクトリ

で、httpd.conf の適当なところに
# ASP.NET
Include conf/extra/httpd-aspdotnet.conf
を追加

で、httpd を起動すれば、一発でOKでした

現状 ASP.NET も特に問題無く動いてますが、1点
PDF をダウンロードする部分が動きませんでした、CSVファイルはダウンロードできるのに・・・

Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "inline; filename=" + Server.UrlEncode("TEST.pdf"))
Response.WriteFile(sPdfName)
Response.End()

って感じで、IISではPDFが表示されるんですが・・・

でも

Dim fs As New System.IO.FileStream(sPdfName, IO.FileMode.Open)
Dim buf(CInt(fs.Length) - 1) As Byte
fs.Read(buf, 0, CInt(fs.Length))
fs.Close()

Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "inline; filename=" + Server.UrlEncode("TEST.pdf"))
Response.BinaryWrite(buf)
Response.End()

こう書き換えたら、動きました

ソースもあるので、最新版用の64bit のモジュールをビルドすればいいかと思ったのですが
Apache2.2 用の32bit 版もなにやらエラーが出たので、あきらめました


まぁ、動きはしましたが、開発終了してるみたいですし、最新のApacheで動かないし
64ビットでもダメなんで、無理して Apache で動かさなくても、IIS で良い気がしてきました




・リモートPCからSQLServerに繋ぐ
・SqlServer壊してしもた・・・
・SqlServerの不思議
・SQLServer のチューニング
・SQLSERVER のリストア
・NetFx3 ってなんだ?
・RDゲートウェイを入れてみました
・Windows上のApcheでASP.NETを動かす
・SQLServer に、大量データのインサート
・Windwos で mono
・XSP が遅い
・XSP をサービスで動かす
・Apache でエラーが出る
・Apache XSP にリバースプロキシかけると遅い?
・XSP で image のローディングに失敗する
・iOS 上の Safari でビープ音を鳴らす
・Windows10 のシステムイメージの作成
・SQL Server 2017 RC2 評価期限切れ

カテゴリー:日記
目次へ戻る


フッターイメージ