检查环境是否支持 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
本文为原创文章,版权归主机之家测评所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ BudgetVM:$29/月-4GB/200GB/100Mbps 不限流量/高防/洛杉矶&日本等机房10/17
- ♥ #真实测评#桔子数据:2 核/2G/50G 硬盘/15Mbps/香港 CN2+BGP 线路套餐测评数据05/25
- ♥ #补货#搬瓦工:DC6 CN2 GIA-E 限量版,$49.99/年,三网直连全程 CN2 GIA,可选 CN2 GIA(DC6/DC9)/日本软银等04/01
- ♥ Rabisu:土耳其 vds,2 核/4G 内存/40G NVMe/1Gbps 无限流量,$2.9/月起,另可选英国/美国/保加利亚机房09/06
- ♥ #补货#傲游主机:香港 cn2 vps,2 核/2G 内存套餐,56 元/月起,可选原生 ip 以及高防套餐11/07
- ♥ Hypere:美国 AMD Ryzen 9 5900X 高性能 VPS,2 核/2GB DDR4 内存/70 GB NVMe/10Gbps 带宽不限流量,季付 14.72 美元,可选美国旧金山/英国伦敦10/12