#topicpath


///////////////////////////////////////////////////////////////////////////////
* 目次 [#mb1b08f6]
#contents();


///////////////////////////////////////////////////////////////////////////////
* 設定 [#a7da24d1]

//=============================================================================
** 設定を変更した時は [#p4973393]
- 再起動が必要になる。
 # /etc/init.d/apache2 restart

//=============================================================================
** 設定の確認 [#p208b5c3]
- モジュールは以下を見れば確認出来る:
++ 有効になっているモジュールは /etc/apache2/mods-enabled
++ 利用可能なモジュールは /etc/apache2/mods-available

///////////////////////////////////////////////////////////////////////////////
* ユーザディレクトリ [#l9799c4f]
- 各ユーザの特定の名前のパスが、apacheにより公開されるようにする設定
- 各ユーザの ${HOME}/public_html/ が、 http://hostname/~username/ として公開される。
- userdir モジュールを使用する。
-  有効化
 # a2enmod userdir



///////////////////////////////////////////////////////////////////////////////
* CGI [#a363a7ce]
//=============================================================================
** CGIの有効化 [#yc21c632]
- まず、*.cgiや *.pl をCGIとして扱わせるようにする
 # vi /etc/apache2/mods-available/mime.conf
 
 # AddHandler allows you to map certain file extensions to "handlers":
 # actions unrelated to filetype. These can be either built into the server
 # or added with the Action directive (see below)
 #
 # To use CGI scripts outside of ScriptAliased directories:
 # (You will also need to add "ExecCGI" to the "Options" directive.)
 #
 AddHandler cgi-script .cgi .pl  # ←コメントアウトを外して有効にする

- CGIプログラム用の特別なディレクトリを用意する場合は、 AcriptAlias ディレクティヴを使用する。
 # vi /etc/apache2/sites-available/default
 
 	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 	<Directory "/usr/lib/cgi-bin">
 		AllowOverride None
  		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 		Order allow,deny
 		Allow from all
 	</Directory>

- 各ユーザディレクトリ内にて、cgi-bin ディレクトリ内だけでcgiが動くようにする場合は、ScriptAlias で定義しない(出来ない?)ので、以下のようにする:
 # vi /etc/apache2/mods-available/userdir.conf
 
 <IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root
 
        <Directory /home/*/public_html> # ← 各ユーザの ${HOME}/public_html が公開ディレクトリになる
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                </Limit>
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all
                </LimitExcept>
        </Directory>
 
        # ↓以下3行を追記する
        <Directory /home/*/public_html/cgi-bin>
                Options +ExecCGI
        </Directory>
 
 </IfModule>


-  /etc/apache2/sites-enabled/000-default.conf の編集
 <VirtualHost *:80>

 </VirtualHost>
の間に、以下を追記する:
 <Directory "/var/www/html">
    AllowOverride All
    Options +ExecCGI
    Require all granted
 </Directory>

- 以下のコマンドを実行
 # a2enmod cgid
 # /etc/init.d/apache2 restart


//=============================================================================
** CGIの設置 [#o9aa07cf]
- パーミッションは r+x 属性が付いてないと動かないようだ。結果、 755 を付けることになる。
-- パーミッションが合ってないと、 /var/log/apache2/error.log に以下のように出力される:
 [Sun May 05 15:01:07 2013] [error] [client 127.0.0.1] Can't open perl script "/home/hoge/public_html/hello.cgi": Permission denied


///////////////////////////////////////////////////////////////////////////////
* SSI [#efc22ad3]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS