Manually installing WebVirtCloud on Ubuntu 20.04

I recently installed WebVirtCloud for a browser-based way of administrating my KVM server remotely.

Originally, I used the auto-install script provided, which required some changes to get it to work/work correctly on Ubuntu Server 20.04.

Looking further into the auto-install script, I decided to document how to do a manual install, as the auto-install script is a git script, and changes made in the future could make it difficult/impossible to install without a lot of work troubleshooting issues.

Manually install WebVirtCloud on Ubuntu Server 20.04

  • Create a file to generate the SECRET_KEY used in the configuration:

    import random, string
    haystack = string.ascii_letters + string.digits + string.punctuation
    print(''.join([random.SystemRandom().choice(haystack) for _ in range(50)]))
    
  • Generate the SECRET_KEY:

    python3 ./secret.key.generator.py
    STz-p!WHsWAX,ZnHj"r"Yw5XfRE(AJr*XItEI/9>KYn%~QcZ`!
    
  • Install WebVirtCloud required packages:

    sudo apt-get install git virtualenv python3-virtualenv python3-dev python3-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python3-guestfs libsasl2-dev libldap2-dev libssl-dev -y
    
  • Clone the git repository, and copy the settings template:

    git clone https://github.com/retspen/webvirtcloud
    
    cd webvirtcloud
    
    cp webvirtcloud/settings.py.template webvirtcloud/settings.py
    
  • Edit the webvirtcloud/settings.py file, and add the SECRET_KEY generated above in the 'SECRET_KEY' line.

  • Remove LDAP from an authentication source in the 'AUTHENTICATION_BACKENDS' section of the config, to avoid receiving a '500 Internal Error' after logging in:

    sed -i '/"webvirtcloud.ldapbackend.LdapAuthenticationBackend",/d' webvirtcloud/settings.py
    
  • Copy configurations, move the webvirtcloud folder, and change permissions:

    sudo cp conf/supervisor/webvirtcloud.conf /etc/supervisor/conf.d
    
    sudo cp conf/nginx/webvirtcloud.conf /etc/nginx/conf.d
    
    cd ..
    
    sudo mv webvirtcloud /srv
    
    sudo chown -R www-data:www-data /srv/webvirtcloud
    
  • Add your user to the www-data group, so you can complete the install:

    sudo usermod -a -G www-data `id -un`
    
  • Log out, then back in, due to permission changes, then create the virtual enviorment:

    cd /srv/webvirtcloud
    virtualenv -p python3 venv
        created virtual environment CPython3.8.5.final.0-64 in 292ms
          creator CPython3Posix(dest=/srv/webvirtcloud/venv, clear=False, global=False)
          seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/tom/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
          activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
    
  • Next steps

    • Active the virtual environment
    • Use pip to install required packages
    • Run manage.py script
    • Change permissions
    • Clean up files
    source venv/bin/activate
    
    pip install -r conf/requirements.txt
    
    python3 manage.py migrate
    
    sudo chown -R www-data:www-data /srv/webvirtcloud
    
    sudo rm /etc/nginx/sites-enabled/default
    
  • Install KVM-related packages, if you haven't already:

    sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager sasl2-bin python3-guestfs supervisor -y
    
  • Add the www-data user to the libvirt group, to allow access to the /var/run/libvirt/libvirt-sock:

    sudo usermod -a -G libvirt www-data
    
  • Add your current user to the libvirt group, in case you ever want to do any command-line work (recommended):

    sudo usermod -a -G libvirt `id -un`
    
  • Modify the libvirtd configuration, so it listens for TCP connections on start up:

    sudo sed -i 's/libvirtd_opts="-d"/libvirtd_opts="-d -l"/g' /etc/default/libvirtd
    
  • Modify the libvirt configuration, so it listens for TCP/TLS connections:

    sudo sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
    
    sudo sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
    
    sudo sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
    
  • Modify the QEMU configuration, so it listens for VNC and Spice remote connections on any interface:

    sudo sed -i 's/#[ ]*vnc_listen.*/vnc_listen = "0.0.0.0"/g' /etc/libvirt/qemu.conf
    
    sudo sed -i 's/#[ ]*spice_listen.*/spice_listen = "0.0.0.0"/g' /etc/libvirt/qemu.conf
    
  • Download gstfsd deamon, which is the WebVirtCloud daemon for managing filesystem in Instance:

    sudo wget -O /usr/local/bin/gstfsd https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd
    
    sudo chmod +x /usr/local/bin/gstfsd
    
    sudo wget -O /etc/supervisor/conf.d/gstfsd.conf https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf
    
  • Restart the 'libvirtd', 'supervisor', and 'nginx' services:

    sudo systemctl restart libvirtd supervisor nginx
    
  • Log into the web interface and enjoy!

References:

Webvirtcloud https://github.com/retspen/webvirtcloud