3

My setup

enter image description here

I want to setup a Ubuntu VM to act as a web server for development.

Reason

I want to have a development environment as close to the actual production environment as possible.

Problem

The above setup failed. I keep getting a File Not Found when I navigate to http://project1.localhost:8888

What I tried

I did add www-data to the group vboxsf using

sudo adduser www-data vboxsf

before trying any of the below.

  1. As mentioned, I tried the above setup. File not found error on webpage.
  2. I tried the above setup but symlink from /var/virtual/project1 to /media/sf_WebApps/project1. File not found error on webpage.
  3. I tried to chown the /media/sf_WebApps from root:vboxsf to www-data:vboxsf. Not possible.
  4. I tried to chmod the /media/sf_WebApps to 755. Not possible.
  5. I made a copy of /media/sf_WebApps/project1 and place the copy inside /var/virtual. This works, but this is not what I want. Why not? Because I want to easily use my host programs like github mac app and sublime text editor to make changes to the code base and see it reflected when I visit on browser.

3 Answers 3

4

The answer is found here from serverfault.

Basically, you need to mount the (already mounted) shared folder as another user.

Type

mount -t vboxsf SHARE_NAME -o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /path/on/guest

In this case, it will be

mount -t vboxsf WebApps -o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /var/virtual/some_folder_name

If you want to do this mount every time you turn on the guest OS, create a file on /etc/init/SOMETHING.conf, with something like this:

description     "SOME DESCRIPTION"

start on starting

task
exec mount -t vboxsf WebApps -o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /var/virtual/some_folder_name

To find out what is your uid or gid

 id -u username
 id -g username

Troubleshooting:

Always remember to first create the mount point first.

Always remember to install the GuestAdditions first. You can refer to http://docs-v1.vagrantup.com/v1/docs/base_boxes.html under Install Guest Additions.

sudo apt-get install linux-headers-$(uname -r) build-essential
sudo apt-get install dkms -y

sudo mount /dev/cdrom /media/cdrom
sudo sh /media/cdrom/VBoxLinuxAdditions.run
1
  1. To edit /etc/group
  2. To find the line contains "vboxsf"
  3. To Add account after the colon (like www-data). If you need to add multiple accounts, you can separate them by commma
  4. Relogin or reboot
1

I did something similar to the @KimStacks solution, but could not get /etc/init/SOMETHING.conf to work on Ubuntu 18.04 LTS, even if I changed start on starting to start on startup like the Stack Overflow example.

I found these steps much easier:

  • Make a permanent mount point (use this location rather than /media once mounted):

    sudo mkdir /some/location
    
  • Get the uid and gid of www-data:

    id www-data
    
  • Edit the crontab file:

    sudo crontab -e
    
  • Add a @reboot line to make it run on boot (replace USER_ID and GROUP_ID with the uid and gid from previous steps):

    @reboot mount -t vboxsf VirtualBoxFolderShareName /some/location -o uid=USER_ID,gid=GROUP_ID
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .