This how-to guide will take you through the installation steps to run the LXD dashboard in an LXC container on your system. This guide will assume that your system already has LXD installed and configured.
Start by launching a new instance using the official Ubuntu 20.04 image. To launch the new instance and name it lxd-dashboard use the following command:
$ lxc launch ubuntu:20.04 lxd-dashboard
This will create a base container to use to install the LXD dashboard. Once the command finishes the container should be running. Now it is time to connect into the container and setup the software. Use the following command to obtain a bash shell connection to the instance, use the exit command at anytime to leave the shell:
$ lxc exec lxd-dashboard /bin/bash
The following commands will now be run inside the lxd-dashboard container. Verify that the terminal prompt reads root@lxd-dashboard:~# before installing any software. The LXD dashboard uses Nginx and PHP for the webserver platform and SQLite as a database. To install these packages use the following command:
$ apt update && apt install nginx php-fpm php-curl sqlite3 php-sqlite3 -y
Using wget, the source code for the LXD dashboard can be downloaded from the GitHub repository. For this guide the v2.2.0 release will be used. Check for newer versions on the GitHub page and replace the version number with the latest. To download and extract the source code use the following two commands:
$ wget https://github.com/lxdware/lxd-dashboard/archive/v2.2.0.tar.gz
$ tar -xzf v2.2.0.tar.gz
A few web server files will need to moved into place for the web pages as well as the NGINX configuration. To copy these files use the following commands, making sure to change the version number to what was downloaded:
$ cp -a lxd-dashboard-2.2.0/default /etc/nginx/sites-available/
$ cp -a lxd-dashboard-2.2.0/lxd-dashboard /var/www/html/
There are three main directories that LXDWARE uses to store persistent information for the application. You will need to create these directories and then assign appropriate ownership to the web server. To create the directories use the following commands:
$ mkdir -p /var/lxdware/data/sqlite
$ mkdir -p /var/lxdware/data/lxd
$ mkdir -p /var/lxdware/backups
The /var/www/html/lxd-dashboard/ directory, the /var/lxdware/ directory, and the contents within them all need to be owned by the web server user. To set the proper permissions run the following commands:
$ chown -R www-data:www-data /var/lxdware/
$ chown -R www-data:www-data /var/www/html
The NGINX web server will need to be restarted to apply the web server configuration changes made above. To restart the web server run the following command:
$ systemctl restart nginx
Congratulations! The container is now setup with the LXD dashboard software. Exit from the bash terminal and return to your LXD host server by using the command:
$ exit
Open a web browser and access the LXD dashboard by entering in the IP address of the instance. Use the lxc list command to view a list of the containers and their IP addresses on your LXD server.
Optional Port Forward Configuration
Port forwarding can be used to make the lxd-dashboard instance accessible to others computers outside of the server. The lxd-dashboard listens on port 80 for web traffic. In this how-to guide the host’s port 80 will be forwarded to the instance’s port 80. For more information on port forwarding view the how-to guide Forwarding host ports to LXD instances.
To create a new profile named proxy-port-80 use the following command:
$ lxc profile create proxy-port-80
To configure the profile to forward the port 80 from the host server to port 80 on the instance, use the following command:
$ lxc profile device add proxy-port-80 hostport80 proxy connect="tcp:127.0.0.1:8080" listen="tcp:0.0.0.0:80"
To apply the newly created profile to the lxd-dashboard instance and begin forwarding port 80 traffic to your instance run the following command:
$ lxc profile add lxd-dashboard proxy-port-80
Open a web browser and access the LXD dashboard by entering in the IP address of the host server.
I like the new look, and great features. Please keep up the great work!!!
Thanks! I appreciate the feedback. Let me know if you have any troubles with the new changes.
Hi,
I was running 1.2.5 and followed the steps to install 1.2.8.
I then followed the steps to install 2.x.x.
Lxdware is now asking for admin password that not appears to be the old one.
Did I skip something or is the how-to here missing steps about setting the password?
nevermind, it suddenly worked oO
I run “echo | htpasswd -c -i /etc/nginx/.htpasswd admin” just once more
I think it may have been an issue with the cache in your browser. Version 2.0.0 will not be using the htpasswd password, as user accounts are now stored in the SQLite database. Glad to hear that it is working for you.
Something, I found with the new gui was:
HOST MEMORY
28.999999999999996%
So I think it may be related to using PHP round() function rather than number_format() function. It seems as though round() doesn’t always format output to the specified precision. I pushed a new update, let me know if it shows back up.
Nice job Matthew! Please keep up the great work.
Hi Matthew,
It appears the issues still persist. I’m running Version: 2.0.2
HOST MEMORY
28.000000000000004%
Possible fix for you
HOST MEMORY
28.000000000000004%
$arr[‘memoryPercentage’] = number_format($memory_used / $memory_total, 2) * 100;
HOST MEMORY
28.01%
$arr[‘memoryPercentage’] = number_format($memory_used / $memory_total * 100, 2);
Thanks. I can’t quite figure out why that is still happening. I will try to get a new update out tomorrow with your change. I may also look to format that in JavaScript code as well, just to make sure.
Made the change you suggested, in my opinion it looks better with the two digits after decimal point, thanks for the suggestion. I used a float type cast on the memory variables in PHP. That may have been the issue with PHP assigning the values as strings and automatically casting them as a different data type for math equations. Let me know if that problem shows up. I had several servers running testing and did not see that long decimal show up.
I just ran the docker command and I’m not being asked for a u:p combo – what is it? I can’t find it anywhere.
William, the username/password combo is now set when you first access the web interface.
Respects! Matthew, Please keep up the great work.
Thank you!
So how do I update from v2 to v3.2 ?
Just copy everything over or repeat the steps here?
The admin page only gives info that there’s an update, not where to get it or how to update.
Yes, you can just repeat the same steps. I have not coded an automatic update script yet, so it has to be done manually.