WebVirtCloud
Python >=3.11 & Django 4.2 LTS
安装支持的操作系统:Ubuntu 20.04/22.04, Debian 10/11, Rocky/Alma/OEL/RHEL 10。它可以安装在虚拟机、物理主机或KVM主机上。
系统要求
- Rocky Linux 10 系统
- root 用户权限
- 至少 2GB 内存
- 支持虚拟化的 CPU
1.快速安装
| Bash |
|---|
| wget https://raw.githubusercontent.com/retspen/webvirtcloud/master/install.sh
chmod 744 install.sh
# run with sudo or root user
./install.sh
|
2.手动安装
生成密钥
在克隆存储库之后生成SECRET_KEY。然后将其放入webvirtcloud/settings.py中
| Python |
|---|
| import random, string
haystack = string.ascii_letters + string.digits + string.punctuation
print(''.join([random.SystemRandom().choice(haystack) for _ in range(50)]))
|
系统更新和基础包安装
| Bash |
|---|
| yum -y install epel-release
dnf config-manager --set-enabled crb
yum -y install python3-virtualenv python3-devel python3-libguestfs \
python3-lxml python3-libguestfs libvirt-devel \
glibc gcc nginx supervisor git iproute-tc \
cyrus-sasl-md5 libguestfs-tools openldap-devel \
openssl-devel cyrus-sasl-devel --skip-broken
|
安装和配置 WebVirtCloud
| Bash |
|---|
| mkdir /srv && cd /srv
git clone https://github.com/retspen/webvirtcloud && cd webvirtcloud
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
# 现在将密钥放入webvirtcloud/settings.py
# 手动创建密钥或者执行下方命令
python3 /srv/webvirtcloud/conf/runit/secret_generator.py
rNXkBQY20b92lQV3WEGGzy0SOjO2re2GRCF80xEAX6DYgDpsMw4v6mD0FXwMoQtRwVk
# 编辑webvirtcloud/settings.py,这里配置两个项
SECRET_KEY = "rNXkBQY20b92lQV3WEGGzy0SOjO2re2GRCF80xEAX6DYgDpsMw4v6mD0FXwMoQtRwVk"
CSRF_TRUSTED_ORIGINS = ['http://本机IP','http://或者域名']
|
开始配置
- 创建一个python 虚拟环境, 安装依赖包
| Bash |
|---|
| # 创建虚拟环境
mkvirtualenv webvirtcloud
# 进入虚拟环境
workon webvirtcloud
# 开始部署
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple \
--trusted-host pypi.tuna.tsinghua.edu.cn -r conf/requirements.txt
cp conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/
python3 manage.py migrate
python3 manage.py collectstatic --noinput
|
- 修改配置文件
vim /etc/supervisord.conf
| Bash |
|---|
| # 在配置文件最后添加
[program:webvirtcloud]
command=/srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py
directory=/srv/webvirtcloud
user=root
autostart=true
autorestart=true
redirect_stderr=true
[program:novncd]
command=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/novncd
directory=/srv/webvirtcloud
user=root
autostart=true
autorestart=true
redirect_stderr=true
|
- 配置nginx
如果不使用root启动,需要给目录授权
vim /etc/nginx/conf.d/webvirtcloud.conf
| Bash |
|---|
| # 注释掉对应冲突的配置,检查复制的webvirtcloud.conf路径有没有问题
upstream gunicorn_server {
#server unix:/srv/webvirtcloud/venv/wvcloud.socket fail_timeout=0;
server 127.0.0.1:8000 fail_timeout=0;
}
server {
listen 80;
# 如果不配置域名,可以写本机IP,对应上边CSRF_TRUSTED_ORIGINS配置
server_name 172.16.1.132 servername.domain.com;
access_log /var/log/nginx/webvirtcloud-access_log;
location /static/ {
root /srv/webvirtcloud;
expires max;
}
location / {
proxy_pass http://gunicorn_server;
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 $remote_addr;
proxy_connect_timeout 1800;
proxy_read_timeout 1800;
proxy_send_timeout 1800;
client_max_body_size 1024M;
}
}
|
- 启动服务
systemctl restart nginx && systemctl restart supervisord
3.浏览器访问
http://ip地址