kvm虚拟化平台学习(一)CentOS7.5下WebVirtMgr部署

本文详细介绍了如何在CentOS7.5上部署WebVirtMgr虚拟化管理平台,包括安装依赖包、配置pip源、安装webvirtmgr程序及第三方库、创建超级管理员、管理静态文件、配置站点、设置supervisor和实现开机自启。
摘要由CSDN通过智能技术生成

1.安装依赖包

yum install -y epel-release
yum clean all && yum makecache
yum install -y git python-pip libvirt-python libxml2-python python-websockify supervisor nginx gcc python-devel

2.配置pip豆瓣源

vim ~/.pip/pip.conf
[global]
timeout = 60
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com

3.下载webvirtmgr程序包

cd /usr/local/src
git clone git://github.com/retspen/webvirtmgr.git

4.使用pip安装第三方库

cd webvirtmgr
pip insall numpy
pip install -r requirements.txt

5.创建超级管理员

python2 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
Username (leave blank to use ‘root’): admin
Email address: xxxx@163.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL …
Installing indexes …
Installed 6 object(s) from 1 fixture(s)

6.管理静态文件

python2 manage.py collectstatic

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

修改时区

sed -i "s#^TIME_ZONE.*#TIME_ZONE = 'Asia/Shanghai'#g" /usr/local/src/webvirtmgr/webvirtmgr/settings.py

配置超级管理员,该步骤为可选操作,个人认为与syncdb中配置管理员功能重复。

python2 manage.py createsuperuser(可略过该操作)

7.配置webvirtmgr站点

mkdir /var/www/
cp -a /usr/local/src/webvirtmgr /var/www/
chown -R nginx. /var/www/webvirtmgr

vim /etc/nginx/conf.d/webvirtmgr.conf
server {
	listen 80 default_server;
    server_name $hostname;
    access_log /var/log/nginx/webvirtmgr_access.log; 
    error_log /var/log/nginx/webvirtmgr_error.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全局配置文件中的default server设定

cp -a /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak`date +%Y$m%d%H%M%S`
vim /etc/nginx/nginx.conf
# 注释掉38~57行

检查并确认是否绑定了8000端口

vim /var/www/webvirtmgr/conf/gunicorn.conf.py
bind = '127.0.0.1:8000'

8.配置supervisor

vim /etc/supervisord.d/webvirtmgr.ini
[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

9.配置开机自启,启动服务

systemctl enable nginx supervisord
systemctl start nginx supervisord
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值