Centos 7安装WebVirtMgr,管理独立服务器,创建KVM VPS

控制端:1.1.1.1
服务器端:2.2.2.2

以下在Centos 7.2下成功使用。

一、控制端安装WebVirtMgr

1、安装必要应用

sudo yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
sudo yum -y install gcc python-devel
sudo pip install numpy

2、安装、设置 python 和 Django

git clone git://github.com/retspen/webvirtmgr.git
cd webvirtmgr
sudo pip install -r requirements.txt
./manage.py syncdb
./manage.py collectstatic

然后,设置用户名和密码。
WebVirtMgr1.jpg

可以添加其他用户

./manage.py createsuperuser

3、设置Nginx

a、使用:8000端口

ssh-keygen
ssh-copy-id 1.1.1.1
ssh 1.1.1.1 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:6080

b、Nginx设置

cd ..
sudo mv webvirtmgr /var/www/

添加webvirtmgr.conf配置文件

vi /etc/nginx/conf.d/webvirtmgr.conf

添加如下内容:

server {
    listen 80 default_server;
    server_name $hostname;
    #access_log /var/log/nginx/webvirtmgr_access_log;
    location /static/ {
        root /var/www/webvirtmgr/webvirtmgr;
        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
    }
}

添加Nginx配置:

vi /etc/nginx/nginx.conf

添加内容:

include /etc/nginx/conf.d/*.conf;

重启nginx

/bin/systemctl restart  nginx.service

c、升级SELinux

/usr/sbin/setsebool httpd_can_network_connect true
sudo  chkconfig supervisord on

d、升级webvirtmgr

cd /var/www/webvirtmgr
sudo git pull
sudo ./manage.py collectstatic
sudo service supervisord restart

4、设置Supervisor
a、运行

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

b、添加配置

vi /etc/supervisord.d/webvirtmgr.ini

添加:

[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

重启supervisor

/bin/systemctl stop  supervisord.service
/bin/systemctl start  supervisord.service

二、服务器端安装KVM

三、使用WebVirtMgr的web方式,管理KVM VPS

四、其他问题

1、pip 可能不存在,安装pip

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

参考:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr
http://www.linuxidc.com/Linux/2016-10/136589p2.htm

    所有主机信息仅是为及时分享并收录,不做推荐!
    专门搜集、分享国内高速、稳定的香港、日本、韩国、新加坡、美西CN2等优质线路的主机:FastVM