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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/monk2014/article/details/85043540

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: [email protected]
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

配置超级管理员,该步骤为可选操作,个人认为与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

猜你喜欢

转载自blog.csdn.net/monk2014/article/details/85043540