WebVirtMgr安装

官方Wiki

Install WebVirtMgr · retspen/webvirtmgr Wiki · GitHub

本地安装环境:

Centos 7.5.1804

1. 添加容器
docker run -itd --privileged -p 8090:80 -p 6080:6080 -p 8000:8000 --name webvirtmgr centos:7.5.1804 /usr/sbin/init
2. 进入容器
docker exec -it webvirtmgr /bin/bash
3. 安装依赖包
yum -y install epel-release
yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx gcc python-devel

pip install numpy==1.16 #1.17及以上版本不支持python2
4. 获取源码
git clone git://github.com/retspen/webvirtmgr.git

cd webvirtmgr
pip install -r requirements.txt  # 使用清华大学镜像站 -i https://pypi.tuna.tsinghua.edu.cn/simple
5. 安装配置
./manage.py syncdb
#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.

./manage.py collectstatic
#WARNING:root:No local_settings file found.
#You have requested to collect static files at the destination
#location as specified in your settings.
#This will overwrite existing files!
#Are you sure you want to do this?
#Type 'yes' to continue, or 'no' to cancel: yes
6. 配置nginx
mkdir -pv /var/www
cp -raf webvirtmgr /var/www/		#将webvirtmgr源码拷贝到/var/www/
chown -R nginx:nginx /var/www/webvirtmgr
vim /etc/nginx/nginx.conf
#注释以下内容
#    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 {
#        }
#    }

vim /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; # or /srv instead of /var
        expires max;
    }

    location ~ .*\.(js|css)$ {
           proxy_pass http://127.0.0.1:8000;
    }

    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 
    }
}
7. 重启nginx
systemctl restart nginx
8. 配置supervisor
chkconfig supervisord on
vim /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

# 在docker中安装webvirtmgr,需要修改/var/www/webvirtmgr/conf/gunicorn.conf.py
vim /var/www/webvirtmgr/conf/gunicorn.conf.py
# 将bind = "127.0.0.1:8000" 修改为
bind = "0.0.0.0:8000"
9. 设置ssh免密
mkdir /home/nginx
chown -R nginx:nginx /home/nginx
chmod -R 700 /home/nginx
su - nginx -s /bin/bash
ssh-keygen
touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
chmod 0600 ~/.ssh/config
ssh-copy-id  remote_kvm_ip
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值