I've recently updated a headless server to Ubuntu Server 15.10.
- Basic Ubuntu Server
- LAMP
- Xubuntu minimal install
I've installed virtualbox 5.0.14 from default Ubuntu sources.
I've downloaded and installed virtualbox/5.0.14/Oracle_VM_VirtualBox_Extension_Pack-5.0.14-105127.vbox-extpack
I've defined a user vbox
in group vboxusers
, and basically virtualbox itself works fine. But I want it to be remotely configurable by using phpvirtualbox.
I downloaded and installed phpvirtualbox-5.0-5.zip
I added the VBOXWEB_USER=vbox
to file /etc/default/virtualbox
.
When visiting the webpage from another machine, I got an error Could not connect to host
(see msg1, and with more details in msg2, not really important though, I think.).
Using sudo netstat -peanut
, it looked like vboxwebsrv was not using the correct IP address. It showed the local address as ::1:18083
instead of the expected 192.168.1.12:18083
.
After some googling, I added VBOXWEB_HOST=192.168.1.12
to file /etc/default/virtualbox
, but still no change after restarting the service.
However, if I stopped the service with sudo systemctl stop vboxweb.service
and started it manually with sudo vboxwebsrv -H 192.168.1.12
, that worked fine. sudo netstat -peanut
now reported it with the expected IP/port adress.
Most of the documentation I looked at referred to init.d and I started thinking that perhaps systemd does not use the /etc/default/virtualbox
file… I found that I could edit the file /lib/systemd/system/vboxweb.service
, and added a -H 192.168.1.12
to the ExecStart
command.
After a restart of the vboxweb service, it worked! :o)
Enabled service so that it would start automatically at boot time:
sudo systemctl enable vboxweb.service
But after rebooting, there was no vboxweb showing in sudo netstat -peanut
at all, although ps -ef showed the service started:
$ps -ef
root 1383 1 0 mars02 ? 00:00:00
/usr/lib/virtualbox/vboxwebsrv –pidfile /run/vboxweb.pid –background
-H 192.168.1.12 -p 18083
A restart of the service will fix it, but it will not come up correctly after reboot.
So I was thinking that perhaps the vboxweb.service was started too early in the systemd initialization process.
So I edited the vboxweb.service
file again, with After=apache2.service
(and later also tried After=multi-user.target
), and verified with systemd-analyse plot
that the init of vboxweb was indeed moved to the very end of the initialization sequence. But still, wboxweb was not listed in netstat -peanut
So finally to my questions:
- Are there conflicts between init.d and systemd, e.g. that virtualbox (from standard Ubuntu sources) relies on files that are init.d specific, while Ubuntu has moved on to systemd?
- Any other reason why the
VBOXWEB_HOST
setting in the/etc/default/virtualbox
file had no effect? - Was it correct to edit the vboxweb.service file (specifically with the host parameter).
- (and this is the important one) How do I get vboxweb service up and running with correct IP/port settings at boot time? I am all out of ideas :/
PS: I know I could have shortened this post a lot, and just kept the main question here, as I have resolved the rest (leaving only a couple of questions), but I thought it could be interesting for others to see how I've worked on this problem.
BR,
Rolf
Best Answer
After some more googling and mucking about, I finally came up with a solution:
1) I concluded that the
/etc/defaults/virtualbox
file did not seem to have any effect on anything (just a remnant from the init.d days?). So the user and group settings in that file was wasted.Solution: Added
User=vbox
andGroup=vboxusers
in the[Service]
section of thevboxweb.service
file.2) Some of the problems I had was due to the
vboxweb.config
file referring to a pid-file in the/run
folder, andvbox
has no write access to that folder. First I tried to make a subfolder, owned byvbox
, in which to store the pid file, but I learned that the/run
folder gets wiped at boot time, including all subfolders.Solution: Created a subfolder in
vbox
homedir, and updatedvboxweb.config
file with that location.3) For some reason (which still eludes me), referring to the actual IP address, 192.168.1.12, in
config.php
(in thephpvirtualbox
folder) and in thevboxweb.config
file (as mentioned in the original post), did not work at boot time. (A later restart of the service would work though.)Solution: Updated both
config.php
andvboxweb.config
with IP address 127.0.0.1 instead of 192.168.1.12.Case closed! :o) ...apart for all the questions about why things are the way they are, but I can live with that :o)
BR, Rolf