On Linux systems, if you installed the official VirtualBox package (e.g. from here), it created the init script /etc/init.d/vboxweb-service or a systemd service file /lib/systemd/system/vboxweb-service.service, depending on your service manager (init or systemd). These can be used to start and stop vboxwebsrv.
In order to start vboxwebsrv, the file /etc/default/virtualbox must exist with correct settings.
Note : If you have installed the VirtualBox package provided with your Linux distribution, the init script or the systemd service file may have a different name or a different location. Moreover, if your Linux distribution use systemd as service manager, your vboxwebsrv systemd service file may ignore the file /etc/default/virtualbox, resulting in an Could not connect to host error. This is the case with the default systemd service file provided with Arch Linux or Ubuntu.
While there may be numerous ways to configure vboxwebsrv, this document aims to keep it simple and suppose you installed the official VirtualBox package. If the file /etc/default/virtualbox does not exist on your system, create it now. This file has the format:
SETTING1=value SETTING2=value
The following settings are available for use in this file:
Setting | Description |
---|---|
VBOXWEB_USER | The user as which vboxwebsrv will run. |
VBOXWEB_HOST | The host to bind to (localhost). |
VBOXWEB_PORT | The port to bind to (18083). |
VBOXWEB_TIMEOUT | Session timeout in seconds; 0 = disable timeouts (300). |
VBOXWEB_CHECK_INTERVAL | Frequency of timeout checks in seconds (5). |
VBOXWEB_THREADS | Maximum number of worker threads to run in parallel (100). |
VBOXWEB_KEEPALIVE | Maximum number of requests before a socket will be closed (100). |
VBOXWEB_LOGFILE | Name of file to write log to (no file). |
INSTALL_DIR | The location of the vboxwebsrv binary (/usr/lib/virtualbox). |
At a minimum, VBOXWEB_USER and VBOXWEB_HOST must be set.
VBOXWEB_USER should be set to the user that runs VirtualBox virtual machines on your system. If more than one user runs virtual machines, you will have to pick one (multiple instances are possible, but beyond the scope of this document). DON'T USE THE ROOT USER, vboxwebsrv WON'T ACCEPT ANY CONNECTION.
VBOXWEB_HOST should, in most cases, be set to 127.0.0.1. If phpVirtualBox (your web server) is not running on the same host as vboxwebsrv and phpVirtualBox must communicate with vboxwebsrv over a network, this must be set to the external IP address of the host runing vboxwebsrv.
Your /etc/default/virtualbox may look like this:
VBOXWEB_USER=vbox VBOXWEB_HOST=127.0.0.1
.. or if your web server and vboxwebsrv are NOT on the same host:
VBOXWEB_USER=remote_vbox VBOXWEB_HOST=192.168.0.4
Note that these values are just examples. The user that runs virtual machines on your system may not be named "vbox."
Once this is done, you may start and stop vboxwebsrv by running as root user:
- If you use init scripts :
- If you use systemd :
/etc/init.d/vboxweb-service start /etc/init.d/vboxweb-service stop
systemctl start vboxweb-service.service systemctl stop vboxweb-service.service