<パッケージのインストール>
~# apt-get install apache2 libapache2-mod-ruby php5 libapache2-mod-php5 php5-gd php-pear
</etc/apache2/apache2.conf(全体設定 )の編集>
以下のコマンドを打つ
~# vi /etc/apache2/apache2.conf
○ 長すぎるURI(414エラー)はログに記録しないに変更
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
↓
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
○読み込みファイルの変更
情報は全く同じなのだが、とりあえず変更
Include /etc/apache2/mods-enabled/*.load
↓
Include /etc/apache2/mods-available/*.load
Include /etc/apache2/mods-enabled/*.conf
↓
Include /etc/apache2/mods-available/*.conf
Include /etc/apache2/sites-enabled/
↓
Include /etc/apache2/sites-available/default
~# vi /etc/apache2/conf.d/security
○ ServerTokensディレクティブを変更
ServerTokens Full
↓
ServerTokens Prod
○HTTP レスポンスヘッダの Apache バージョンを非表示にする
ServerSignature On
↓
ServerSignature Off
○ デフォルトの文字コードを変更する
このapache2では、デフォルトでUTF-8となっています。
このサーバで公開するページの文字コードをすべて統一できるのであれば、その文字コードに変更します。
複数の文字コードが混在する可能性があるのなら、設定をoffにして、各ページごとに文字コード設定を埋めます。
ここではapache2の文字コードはoffに設定し、各ページのmetaタグでcharsetを設定するようにします。
~# vi /etc/apache2/conf.d/charset
#AddDefaultCharset UTF-8
↓
AddDefaultCharset off
○ スクリプト拡張子が動くようにする。
~# vi /etc/apache2/mods-available/mime.conf
#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl .rb
~# vi /etc/apache2/sites-available/default
○ エラーページ等に表示される管理者メールアドレスを指定
ServerAdmin webmaster@localhost
↓
ServerAdmin 【メールアドレス】
○ optionを変更CGI,SSIの許可出来るようにする
<Directory /var/www/>内の
Options Indexes FollowSymLinks MultiViews
↓
Options Includes ExecCGI FollowSymLinks
○ AllowOverrideを変更.htaccessの許可
AllowOverride None
↓
AllowOverride All
○ リンク方法を記述(ファイル名を指定しないときのリンク先を設定)
~# vi /etc/apache2/mods-available/dir.conf
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
↓
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.rb
○ユーザーディレクトリ(~/public_htmlディレクトリ)用モジュールを起動
apache2の再起動
~# /etc/init.d/apache2 restart
~# /usr/sbin/a2enmod userdir
~# /usr/sbin/a2enmod cgi
~# /usr/sbin/a2enmod php5
~# /usr/sbin/a2enmod mime_magic
○
~# vi /etc/apache2/mods-available/dir.conf
~# vi /etc/apache2/mods-available/userdir.conf
UserDir disabled root
↓
#UserDir disabled root
その下に追加
AliasMatch ^/userdir/([^/]+)/(.*) /home/$1/public_html/$2
AllowOverride FileInfo AuthConfig Limit
↓
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
↓
Options IncludesNoExec ExecCGI FollowSymLinks
次回に続く