「ruby/サンプル/@pagesでruby/環境構築(apache2 ドキュメントルートでCGIを動かそう)」の編集履歴(バックアップ)一覧はこちら

ruby/サンプル/@pagesでruby/環境構築(apache2 ドキュメントルートでCGIを動かそう)」(2012/11/11 (日) 23:41:29) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

* 環境構築(apache2 ドキュメントルートでCGIを動かそう) apache2の標準設定ではCGIは「/cgi-bin」配下で動作します。 これをドキュメントルート配下全てのディレクトリでCGIが動くように変更しましょう。 * httpd.conf編集(C:\apache2\conf\httpd.conf) * 1.ドキュメントルートのディレクトリ設定を変更します。 httpd.confを開くと以下のようなコメントがいっぱいのディレクトリ設定のブロックがあります。 #highlight(){{ # # This should be changed to whatever you set DocumentRoot to. # <Directory "C:/apache2/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> }} この中の、「Options」に「ExecCGI」を追加します。 #highlight(){{ Options Indexes FollowSymLinks ↓ Options Indexes FollowSymLinks ExecCGI }} * 2.AddHandlerの設定 「/cgi-bin」でCGIを動かす分には不要ですが、ドキュメントルートに「ExecCGI」を追加して動かす場合、AddHandlerの設定が必要です。 以下のような記述をhttpd.confから探して、コメントを解除します。 #highlight(){{ <IfModule mime_module> 省略 # AddHandler cgi-script .cgi 省略 <IfModule mime_module> }} こんな感じ #highlight(){{ # AddHandler cgi-script .cgi ↓ AddHandler cgi-script .cgi }} 「.rb」ファイルでrubyのCGIを動かしたい場合は以下のようにするとよいです。 #highlight(){{ AddHandler cgi-script .cgi .rb }} * apache2再起動 httpd.confの設定が終わったら、apache2を再起動し「http://localhost/hello.cgi」にアクセスするとCGIが動く筈です。 ※「C:\apache2\htdocs」に前回作った「hello2.cgi」をコピーしました。 &ref(環境構築3-1.png) 設定が上手くできてない場合、以下の様な画面が出ると思います。 その場合は…がんばれ! &ref(環境構築3-2.png)

表示オプション

横に並べて表示:
変化行の前後のみ表示: