How to install Webvirtmanager in Centos
WebVirtMgr is a libvirt-based Web interface for managing virtual machines. It allows you to create and configure new domains, and adjust a domain's resource allocation. A VNC viewer presents a full graphical console to the guest domain. KVM is currently the only hypervisor supported.
This article explains the detailed steps to install Webvirtmanager in Centos.
Step1: Login to the server as root via ssh.
Step2: Disable SELinux.
Step3: Stop firewalld service.
#systemctl stop firewalld
Step4: Disable firewalld service from startup.
#systemctl disable firewalld
Step5: Install packages libvirt-bin and KVM.
#yum -y install kvm libvirt
Step6: Open the file '/etc/sysconfig/libvirtd'.
#vi /etc/sysconfig/libvirtd
Step7: Uncomment the following line and save the file.
LIBVIRTD_ARGS="--listen"
Step8: Open the file '/etc/libvirt/libvirtd.conf'.
#vi /etc/libvirt/libvirtd.conf
Step9: Uncomment the following lines and save the file.
listen_tls = 0
listen_tcp = 1
Step10: Start the libvirtd daemon.
#systemctl start libvirtd
Step11: Enable libvirtd daemon to run during startup.
#systemctl enable libvirtd
Step12: Add users to libvirt and set their passwords using the saslpasswd2 command.
#saslpasswd2 -a libvirt admin
This will ask for the password as the standard input.
To see a list of all accounts the sasldblistusers2 command can be used.
#sasldblistusers2 -f /etc/libvirt/passwd.db
admin@webvirtmgr.net: userPassword
To disable a user's access, use the command saslpasswd2 with the -d
#saslpasswd2 -a libvirt -d admin
Step13: Open access to ports libvirt in iptables firewall.
#iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 16509 -j ACCEPT
Step14: Verify the libvirt connection.
#virsh -c qemu+tcp://IPADDRESS/system nodeinfo
Where IPADDRESS need to be replaced with the ipaddress of the server.
Here we need to provide the username and password that created earlier as the standard input.
Step15: Install EPEL repository.
#yum -y install epel-release
Step16: Install webvirtmgr and all the other required packages
#yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx gcc python-devel
Step17: Install Python module numpy.
#pip install numpy
Step18: Clone the Webvirtmanager files.
#git clone git://github.com/retspen/webvirtmgr.git
Step19: Change the location to cloned folder.
#cd webvirtmgr
Step20: Install python requirements and setup Django environment
#pip install -r requirements.txt
Step21: Configure the Webvirtmanager.
#python2 manage.py syncdb
#python2 manage.py collectstatic
We can create the Django admin user during this command. This will be the login credentials for Webvirtmanager GUI portal.
To add additional superusers if required, run the following command.
#python2 manage.py createsuperuser
Step22: Exit from the Webvirtmanager folder.
#cd ..
Step23: Create the document root folder.
#mkdir /var/www
Step24: Move webvirtmgr files to document root
#mv webvirtmgr /var/www/
Step25: Create the virtualhost configuration file for Webvirtmanager.
#vi /etc/nginx/conf.d/webvirtmgr.conf
Step26: Update the following lines to the file and save.
server {
listen 80 default_server;
server_name $hostname;
access_log /var/log/nginx/webvirtmgr_access_log;
location /static/ {
root /var/www/webvirtmgr/webvirtmgr; # or /srv instead of /var
expires max;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M; # Set higher depending on your needs
}
}
Step27: Open nginx main configuration file.
#vi /etc/nginx/nginx.conf
Step28: Commentout the following lines and save the file.
# server {
# listen 80 default_server;
# server_name localhost;
# root /usr/share/nginx/html;
#
# #charset koi8-r;
#
# #access_log /var/log/nginx/host.access.log main;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# # redirect server error pages to the static page /40x.html
# #
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# # redirect server error pages to the static page /50x.html
# #
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
Step29: Restart nginx service.
#systemctl restart nginx
Step30: Configure nginx to run in startup.
#systemctl enable nginx
Step31: Correct the ownership of webvirtmgr files.
#chown -R nginx:nginx /var/www/webvirtmgr
Step32: Update the following lines at the end of the config file '/etc/supervisord.conf'.
[program:webvirtmgr]
command=/usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[program:webvirtmgr-console]
command=/usr/bin/python2 /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
Step33: Restart supervisor daemon.
#systemctl restart supervisord
Step34: Enable supervisor daemon to run in startup.
#systemctl enable supervisord
Step35: Access Webvirtmanager GUI portal in browser.
http://IPADDRESS
Where IPADDRESS need to be replaced with the ipaddress of the server.
We can use the following command to run the Webvirtmanager for debugging purpose if the above url giving any error.
#/usr/bin/python2 manage.py runserver 0:8000
Then we can access the portal using the following url.
http://IPADDRESS:8000
Where IPADDRESS need to be replaced with the ipaddress of the server.
Step36: Add the libvirt connection to the Webvirtmanager GUI.
Add Connection
Here we need to provide the libvirt username and password that created earlier.
Step37: Configure bridge network.
Step38: Add the bridge network to to the Webvirtmanager GUI.
Networks >> New Network
Step39: Add storage for OS images.
Storages >> New Storage
Step40: Add storage for virtual machines
Storages >> New Storage
Now the system is ready and we can create virtual machines according to the requirements.
That's all…….