LoginSignup
36
36

More than 5 years have passed since last update.

VirtualBoxのCentOS7にGuestAdditionsをインストール

Last updated at Posted at 2015-03-23

ローカルで開発したCakeアプリを、VirtualBox上のCentOSでマウントしてApacheで動かす。
VirtualBoxの共有フォルダの機能を用いるためにGuestAdditionsをインストールする。

構成

  • VirtualBox 4.3.26
  • ゲストOS CentOS [ Linux release 7.0.1406 (Core) ]
  • ホストOS OSX10.10

GuestAdditionsをインストール

  • GuestAdditionをマウント

mkdir -p /mnt/cdrom
mount -r /dev/cdrom /mnt/cdrom/
  • 必要なパッケージをインストール

yum install -y bzip2 gcc make kernel-devel kernel-headers dkms gcc-c++
  • 再起動

reboot
  • GuestAdditionsをインストール

sh /mnt/cdrom/VBoxLinuxAdditions.run

ローカルのWebrootディレクトリをマウントする


mount -t vboxsf -o uid=$(id apache -u),gid=$(id apache -g) local_webroot_dir /var/www/html/

マウントする際にApacheが所有権を持つようにしておく。
/etc/rc.localにも記載しておくと、リブートしたときにもマウントしてくれる。

VirtualBoxでApacheを動かすことについて追記

  • 下記設定を入れないと、CSSなどが文字化けしてうまく読み込めないことがある
httpd.conf

EnableMMAP Off
EnableSendfile Off

参考: VirtualBoxの共有ディレクトリの静的ファイルをApacheから読むと文字化けする問題

  • SELinuxが有効だと403エラーを吐くので注意する。
36
36
0

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
36
36