检查环境是否支持KVM
cat /proc/cpuinfo | egrep 'vmx|svm'
若环境支持则有内容返回
关闭SELinux
vi /etc/sysconfig/selinux
修改 SELinux=enforcing 为 SELinux=disabled
使用yum软件包管理器安装kvm
yum -y install qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools bridge-utils virt-install
检查KVM模块是否被加载
lsmod | grep kvm
若被正确加载则返回如下
kvm_intel 249856 0 kvm 655360 1 kvm_intel irqbypass 16384 1 kvm
配置libvirt启用TCP服务 命令行输入
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf LIBVIRTD_ARGS="--listen"
修改 /etc/sysconfig/libvirtd 文件
去除 LIBVIRTD_ARGS="–listen" 前的#号
修改 /etc/libvirt/libvirtd.conf 文件对应内容
listen_tls = 0 listen_tcp = 1 tcp_port = "16509" auth_tcp = "none"
若为单机运行则需修改为 listen_addr = "127.0.0.1" 否则需修改为listen_addr = "0.0.0.0"
开启服务并且设置开机自启动
systemctl start libvirtd systemctl enable libvirtd
检查运行状态
systemctl status libvirtd
若显示 Active: active (running) 则运行正常
2.安装WebVirtCloud
安装依赖
yum -y install python-virtualenv python-devel libvirt-devel glibc gcc nginx supervisor python-lxml git python-libguestfs
下载WebVirtCloud
mkdir /srv cd /srv git clone https://github.com/retspen/webvirtcloud cd webvirtcloud cp webvirtcloud/settings.py.template webvirtcloud/settings.py
设置数据库密码
vi webvirtcloud/settings.py
修改 SECRET_KEY = '这里写密码' 注意不要使用除下划线外的特殊字符,可能会出现奇怪的Bug
安装Python库并设置环境
virtualenv venv source venv/bin/activate # 安装pip依赖 (国内源) venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Django==1.11.14 venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple websockify==0.8.0 venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gunicorn==19.9.0 venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple lxml==4.2.3 venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytz # 安装pip依赖 (海外源) venv/bin/pip install Django==1.11.14 venv/bin/pip install websockify==0.8.0 venv/bin/pip install gunicorn==19.9.0 venv/bin/pip install lxml==4.2.3 venv/bin/pip install pytz
查看 libvirt-python 版本号并且安装库
命令行输入:
yum info libvirt-python
查看版本号
安装库:
# 国内源 venv/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple libvirt-python==版本号 #海外源 venv/bin/pip install libvirt-python==版本号
复制网站配置文件并且安装
cp conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/ venv/bin/python manage.py migrate
设置进程守护
vi /etc/supervisord.conf
在末尾添加如下内容
[program:webvirtcloud] command=/srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py directory=/srv/webvirtcloud user=nginx autostart=true autorestart=true redirect_stderr=true [program:novncd] command=/srv/webvirtcloud/venv/bin/python /srv/webvirtcloud/console/novncd directory=/srv/webvirtcloud user=nginx autostart=true autorestart=true redirect_stderr=true
注释掉Nginx默认站点
vi /etc/nginx/nginx.conf
注释掉下面内容
# server { # listen 80 default_server; # listen [::]:80 default_server; # server_name _; # root /usr/share/nginx/html; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # }
添加网站目录权限
chown -R nginx:nginx /srv/webvirtcloud
配置系统服务
# 重启生效配置文件 systemctl restart nginx systemctl restart supervisord # 开机自启动 systemctl enable nginx systemctl enable supervisord
结束
访问 http://IP地址/ 即可看到控制面板,默认账户 admin 密码为 admin
评论前必须登录!
立即登录 注册