2009年9月11日金曜日

Web Deploy with MonoDevelop 2.0

例えば、NTropy を MonoDevelop で Apache + mod_mono 環境に配置する場合。

配置先

開発ユーザー: sta、配置先: /opt/mono/www/ntropy とした場合

$ sudo mkdir -p /opt/mono/www/ntropy
$ sudo chown sta /opt/mono/www/ntropy

Web 配置設定

MonoDevelop メニューから プロジェクト > オプション > 配置 > Web配置ターゲット を選択し、追加 ボタンを押下。配置先情報を入力する。



「App_Data」ディレクトリを配置する場合、そこに何かファイルが含まれる必要がある。



「aspnetdb.sqlite」は、Membership で使用する SQLite DB ファイル(NTropy では使用していないが)。

ちなみに、プロパティ > 配置 > include in deploy にチェックを入れると、「aspnetdb.sqlite」は「bin」ディレクトリ配下に配置された。

Web 配置実行

プロジェクト > Webに配置... を選択し、配置 ボタン押下。





グループ、権限の変更:

$ sudo chown -R :www-data /opt/mono/www/ntropy
$ sudo chmod -R g+w /opt/mono/www/ntropy/App_Data

Apache 設定

/etc/apache2/sites-available/ntropy:
  1. <VirtualHost *:80>  
  2.   Include ./sites-available/include/ntropy  
  3. </VirtualHost>  
/etc/apache2/sites-available/include/ntropy:
  1. ServerName www.ntropy.home  
  2. ServerAdmin web-admin@www.ntropy.home  
  3. DocumentRoot /opt/mono/www/ntropy  
  4. # MonoServerPath can be changed to specify which version of ASP.NET is hosted  
  5. # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0  
  6. # For SUSE Linux Enterprise Mono Extension, uncomment the line below:  
  7. # MonoServerPath www.ntropy.home "/opt/novell/mono/bin/mod-mono-server2"  
  8. # For Mono on openSUSE, uncomment the line below instead:  
  9. MonoServerPath www.ntropy.home "${MONO_HOME}/bin/mod-mono-server2"  
  10.   
  11. # To obtain line numbers in stack traces you need to do two things:   
  12. # 1) Enable Debug code generation in your page by using the Debug="true"   
  13. #    page directive, or by setting <compilation debug="true" /> in the   
  14. #    application's Web.config  
  15. # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging  
  16. MonoDebug www.ntropy.home true  
  17.   
  18. # The MONO_IOMAP environment variable can be configured to provide platform abstraction  
  19. # for file access in Linux.  Valid values for MONO_IOMAP are:  
  20. #    case  
  21. #    drive  
  22. #    all  
  23. # Uncomment the line below to alter file access behavior for the configured application  
  24. #MonoSetEnv www.ntropy.home MONO_IOMAP=all  
  25. #  
  26. # Additional environtment variables can be set for this server instance using   
  27. # the MonoSetEnv directive.  MonoSetEnv takes a string of 'name=value' pairs   
  28. # separated by semicolons.  For instance, to enable platform abstraction *and*   
  29. # use Mono's old regular expression interpreter (which is slower, but has a  
  30. # shorter setup time), uncomment the line below instead:  
  31. # MonoSetEnv www.ntropy.home MONO_IOMAP=all;MONO_OLD_RX=1  
  32.   
  33. MonoApplications www.ntropy.home "/:/opt/mono/www/ntropy"  
  34. <Location "/">  
  35.   MonoSetServerAlias www.ntropy.home  
  36.   SetHandler mono  
  37.   SetOutputFilter DEFLATE  
  38.   SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary  
  39. </Location>  
  40. <IfModule mod_deflate.c>  
  41.   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript  
  42. </IfModule>  
  43.   
  44. CustomLog /var/log/apache2/access.log combined  

設定の有効化:

$ sudo a2ensite ntropy

「/etc/hosts」に追加:
  1. # added for monodemo, ntropy  
  2. 192.168.1.x     www.monodemo.home www.ntropy.home  

Apache 再起動:

$ sudo /etc/init.d/apache2 restart

確認:


再配置

「Web 配置実行」後、mod_mono Control Panel より www.ntropy.home > Restart Server を選択。



ローカルで試す分には、大体、こんなところか。

0 件のコメント:

コメントを投稿