LoginSignup
7
6

More than 3 years have passed since last update.

CentOS 6.6 に Guest Additions をインストールする

Last updated at Posted at 2015-07-10

CentOS 6.6 に Guest Additions をインストールする

CentOS 6.6 で VirtualBox の共有フォルダーを利用するために VirtualBox Guest Additions をインストールする手順のまとめ。

Guest Additions のインストール

Guest AdditionsのCDイメージを挿入

メニューバーの「デバイス」メニューの「Guest Additions のCDイメージを挿入...」を選択。

Guest Additionsのインストーラーの実行

$ yum install gcc perl kernel-devel
$ mount -r /dev/cdrom /mnt
$ sh /mnt/VBoxLinuxAdditions.run

共有フォルダーの設定

共有フォルダーの追加

「フォルダーのパス」は共有したいホストOS側のフォルダーを指定する。
「フォルダー名」はゲストOS側で指定する際に使うラベル名なので任意に指定する。
「自動マウント(A)」「永続化する(M)」にチェックを入れる。

自動マウントの設定

$ echo -e "\nmount -t vboxsf -o uid=\$(id apache -u),gid=\$(id apache -g) webroot /var/www/html" >> /etc/rc.local

シンボリックリンクの作成許可

以下のコマンドをホストOS側で実行する。

$ vboxmanage setextradata VBoxInternal2/SharedFoldersEnableSymlinksCreate/webroot 1

Apacheの設定

Apache のメモリマッピングと sendfile サポートの無効化

DocumentRoot を共有フォルダとしてマウントすると、ファイルを更新しても反映されなかったり文字化けしたりすることがあるので、Apacheの設定を変更して無効化する。

Apache2.2
$ sed -i \
      -e '/#EnableMMAP off/s/^#//' \
      -e '/#EnableSendfile off/s/^#//' \
      /etc/httpd/conf/httpd.conf;
$ httpd -t
$ service httpd restart

EnableMMAP ディレクティブ

NFS マウントされた DocumentRoot では、httpd がメモリマップしている間にファイルが削除されたり 短くなったりしたときに起こるセグメンテーションフォールトのために httpd がクラッシュする可能性があります。
http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
http://httpd.apache.org/docs/2.4/mod/core.html#enablemmap

EnableSendfile ディレクティブ

ネットワークマウントされた DocumentRoot (例えば NFS や SMB) では、カーネルは自身のキャッシュを使ってネットワークからのファイルを送ることができないことがあります。
http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
http://httpd.apache.org/docs/2.4/mod/core.html#enablesendfile

SELinux の無効化

SELinux が有効になっていると403エラーが発生するので無効にする。

SELinux の確認

SELinux が有効になっているか確認。 getenforce コマンドを実行して Enforcing が返ってきたら有効になっている。

$ getenforce
Enforcing

$ sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
$ setenforce 0
$ sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

SELinuxの無効の確認

$ getenforce
Disabled

$ sestatus
SELinux status:                 disabled
7
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6