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: Install packages libvirt-bin and KVM

#yum -y install kvm libvirt

Step2: Open the file '/etc/sysconfig/libvirtd' and uncomment the following line

LIBVIRTD_ARGS="--listen"

Step3: Open the file /etc/libvirt/libvirtd.conf and uncomment the following lines

listen_tls = 0

listen_tcp = 1

Step4: Start the daemon libvirtd

#service libvirtd start

Step5: Add users and set their passwords with the saslpasswd2 command. When running this command it is important to tell it that the appname is libvirt.

# saslpasswd2 -a libvirt admin

Password: xxxxxx

Again (for verification): xxxxxx

To see a list of all accounts the sasldblistusers2 command can be used. This command expects to be given the path to the libvirt user database, which is kept in /etc/libvirt/passwd.db

# 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

Step6: Open access to ports libvirt in firewall

# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 16509 -j ACCEPT

Step7: Verify the connection

Before you add the ip address of your server in the control center perform the following test

$ virsh -c qemu+tcp://IP_address/system nodeinfo

Please enter your authentication name: admin

Please enter your password: xxxxxx

CPU model: x86_64

CPU(s): 2

CPU frequency: 2611 MHz

CPU socket(s): 1

Core(s) per socket: 2

Thread(s) per core: 1

NUMA cell(s): 1

Memory size: 2019260 kB

Step8: Install webvirtmgr and dependent packages

For CentOS/RHEL 6.x,

#yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

#yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx

For CentOS 7.x,

#yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

#yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx

#yum -y install gcc python-devel

#pip install numpy

Step9: Install python requirements and setup Django environment

#git clone git://github.com/retspen/webvirtmgr.git

#cd webvirtmgr

#pip install -r requirements.txt

#./manage.py syncdb

#./manage.py collectstatic

Enter the user information:

You just installed Django's auth system, which means you don't have any superusers defined.

Would you like to create one now? (yes/no): yes (Put: yes)

Username (Leave blank to use 'admin'): admin (Put: your username or login)

E-mail address: username@domain.local (Put: your email)

Password: xxxxxx (Put: your password)

Password (again): xxxxxx (Put: confirm password)

Superuser created successfully.

To add additional superusers

Run:

$ ./manage.py createsuperuser

Step10: Copy webvirtmgr files to document root

#cd ..

#mv webvirtmgr /var/www/

Step11: Create virtualhost file webvirtmgr.conf in /etc/nginx/conf.d and update the below content.

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

}

}

Step12: Open nginx configuration file /etc/nginx/nginx.conf and comment out the below lines

# 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 {

# }

# }

Step13: Restart nginx service

#service nginx restart

Step14: Configure nginx to run in startup.

#chkconfig supervisord on

Step15: Correct the ownership of webvirtmgr files

#chown -R nginx:nginx /var/www/webvirtmgr

Step16: Update the following lines at the end of the config file '/etc/supervisord.conf'

[program:webvirtmgr]

command=/usr/bin/python /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/python /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

Step18: Restart supervisor daemon

#service supervisord stop

#service supervisord start

Step19: Update the files of webvirtmgr

#cd /var/www/webvirtmgr

#git pull

#./manage.py collectstatic

#service supervisord restart

Step20: Load GUI portal in browser

http://x.x.x.x

If you have error or not run panel (only for DEBUG or DEVELOP):

$ ./manage.py runserver 0:8000

Enter in your browser:

http://x.x.x.x:8000 (x.x.x.x - your server IP address )

Step21: Configure bridge network

Step22: Add storage for OS images

Step23: Add storage for virtual machines

Step24: Create instances

 

That's all.......

Leave a Reply

Your email address will not be published. Required fields are marked *