https://www.cnblogs.com/nulige/p/9236191.html
官网:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr
检查是否支持虚拟化
egrep '(vmx|svm)' --color=always /proc/cpuinfo
egrep '(vmx|svm)' /proc/cpuinfo
[root@kvm-server ~]# egrep '(vmx|svm)' /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
[root@kvm-server ~]#
查看KVM模块
lsmod | grep kv
[root@kvm-server ~]# lsmod | grep kv
kvm_intel 188644 0
kvm 621480 1 kvm_intel
irqbypass 13503 1 kvm
[root@kvm-server ~]#
添加源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum -y install epel-release
安装常用包
yum install net-tools vim lrzsz wget -y
yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install virt-manager python-virtinst libvirt-client virt-viewer -y
安装KVM
yum install -y virt-* qemu-kvm libvirt bridge-utils qemu-kvm-tools
检查服务 libvirtd
[root@kvm-server ~]# systemctl status libvirtd
[root@kvm-server ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:libvirtd(8)
https://libvirt.org
[root@kvm-server ~]# systemctl enable libvirtd
[root@kvm-server ~]# systemctl restart libvirtd
[root@kvm-server ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-11-09 23:59:48 CST; 2s ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 2369 (libvirtd)
Tasks: 19 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─2369 /usr/sbin/libvirtd
├─2478 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libv...
└─2479 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libv...
Nov 09 23:59:48 kvm-server dnsmasq[2475]: listening on virbr0(#3): 192.168.122.1
Nov 09 23:59:48 kvm-server dnsmasq[2478]: started, version 2.76 cachesize 150
Nov 09 23:59:48 kvm-server dnsmasq[2478]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-c...inotify
Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: DHCP, sockets bound exclusively to interface virbr0
Nov 09 23:59:48 kvm-server dnsmasq[2478]: reading /etc/resolv.conf
Nov 09 23:59:48 kvm-server dnsmasq[2478]: using nameserver 114.114.114.114#53
Nov 09 23:59:48 kvm-server dnsmasq[2478]: read /etc/hosts - 2 addresses
Nov 09 23:59:48 kvm-server dnsmasq[2478]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Hint: Some lines were ellipsized, use -l to show in full.
[root@kvm-server ~]#
[root@kvm-server ~]# virsh -c qemu:///system list
Id Name State
----------------------------------------------------
[root@kvm-server ~]#
[root@kvm-server ~]# virsh --version
4.5.0
[root@kvm-server ~]# virt-install --version
1.5.0
[root@kvm-server ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
[root@kvm-server ~]# lsmod |grep kvm
kvm_intel 188644 0
kvm 621480 1 kvm_intel
irqbypass 13503 1 kvm
[root@kvm-server ~]#
查看桥接网络
[root@kvm-server ~]# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.525400eb1918 yes virbr0-nic
[root@kvm-server ~]#
man virt-install
virt-install --connect qemu:///system --name=a --os-variant=winxp --ram=1024 --vcpus=1 --disk path=/var/lib/libvirt/images/a.qcow2,format=qcow2,size=18,bus=virtio --accelerate
--vnc --vncport=5909 --vnclisten=0.0.0.0 --noautoconsole --disk path=/tmp/wuns.iso,device=cdrom --disk path=/tmp/virtio-win-0.1.141_amd64.man,device=floppy,perms=rw
virt-install --connect qemu:///system --name=a --os-variant=rhel7 --ram=1024 --vcpus=1 --disk path=/var/lib/libvirt/images/b.qcow2,format=qcow2,size=18,bus=virtio --accelerate --vnc --vncport=5908 --vnclisten=0.0.0.0 --noautoconsole --disk path=/tmp/ CentOS-7-x86_64-Everything-1804.iso,device=cdrom
Virt-manage
安装webvirtmgr
依赖包
yum install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx -y
git-hub中下载相关的webvirtmgr代码
[root@kvm-server ~]# cd /usr/local/src/
[root@kvm-server src]# git clone git://github.com/retspen/webvirtmgr.git
Cloning into 'webvirtmgr'...
remote: Enumerating objects: 5614, done.
remote: Total 5614 (delta 0), reused 0 (delta 0), pack-reused 5614
Receiving objects: 100% (5614/5614), 2.98 MiB | 47.00 KiB/s, done.
Resolving deltas: 100% (3602/3602), done.
[root@kvm-server src]# ll
total 4
drwxr-x--- 20 root root 4096 Nov 10 00:37 webvirtmgr
[root@kvm-server src]#
临时更换pip国内源:
pip install some-package -i https://mirrors.aliyun.com/pypi/simple/
[root@kvm-server src]# cd webvirtmgr/
[root@kvm-server webvirtmgr]# pwd
/usr/local/src/webvirtmgr
[root@kvm-server webvirtmgr]#
[root@kvm-server webvirtmgr]# pip install some-package -i https://mirrors.aliyun.com/pypi/simple/
Collecting some-package
Downloading https://mirrors.aliyun.com/pypi/packages/e7/a2/d318a685319c3801db1ae0002fc8e095663a55546c62a6e30d9d0fc3289b/some-package-0.1.zip
Installing collected packages: some-package
Running setup.py install for some-package ... done
Successfully installed some-package-0.1
You are using pip version 8.1.2, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@kvm-server webvirtmgr]# pip install -r requirements.txt
Collecting django==1.5.5 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/38/49/93511c5d3367b6b21fc2995a0e53399721afc15e4cd6eb57be879ae13ad4/Django-1.5.5.tar.gz (8.1MB)
100% |████████████████████████████████| 8.1MB 10kB/s
######失败再次安装
[root@kvm-server webvirtmgr]# pip install -r requirements.txt
Collecting django==1.5.5 (from -r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/38/49/93511c5d3367b6b21fc2995a0e53399721afc15e4cd6eb57be879ae13ad4/Django-1.5.5.tar.gz
Collecting gunicorn==19.5.0 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/f9/4e/f4076a1a57fc1e75edc0828db365cfa9005f9f6b4a51b489ae39a91eb4be/gunicorn-19.5.0-py2.py3-none-any.whl (113kB)
100% |████████████████████████████████| 122kB 81kB/s
Collecting lockfile>=0.9 (from -r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/c8/22/9460e311f340cb62d26a38c419b1381b8593b0bb6b5d1f056938b086d362/lockfile-0.12.2-py2.py3-none-any.whl
Installing collected packages: django, gunicorn, lockfile
Running setup.py install for django ... done
Successfully installed django-1.5.5 gunicorn-19.5.0 lockfile-0.12.2
You are using pip version 8.1.2, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@kvm-server webvirtmgr]#
[root@kvm-server webvirtmgr]# ./manage.py syncdb
WARNING:root:No local_settings file found.
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table servers_compute
Creating table instance_instance
Creating table create_flavor
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'):
Email address:
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)
[root@kvm-server webvirtmgr]#
[root@kvm-server webvirtmgr]# ./manage.py collectstatic
WARNING:root:No local_settings file found.
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
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/bootstrap.min.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/signin.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/table-sort.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/webvirtmgr.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.eot'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.svg'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.ttf'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.woff'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/asc.gif'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/bg.gif'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/desc.gif'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/favicon.ico'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/Chart.min.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/bootstrap-multiselect.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/bootstrap.min.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/infrastructure.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery-1.10.2.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery-migrate-1.2.1.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery.tablesorter.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.ttf'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.woff'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/base.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/base64.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/black.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/blue.css'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/des.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/display.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/input.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/jsunzip.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/logo.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/playback.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/rfb.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/ui.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/util.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/websock.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/webutil.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/chrome-app/tcp-client.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/README.txt'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/WebSocketMain.swf'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/swfobject.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/web_socket.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/atKeynames.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/bitmap.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/cursor.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/display.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/enums.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/filexfer.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/inputs.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/jsbn.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/lz.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/main.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/playback.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/png.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/prng4.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/quic.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/resize.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/rng.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/rsa.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/sha1.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/simulatecursor.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicearraybuffer.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spiceconn.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicedataview.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicemsg.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicetype.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/ticket.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/utils.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/webm.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/wire.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/jsbn.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/prng4.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rng.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rsa.js'
Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/sha1.js'
75 static files copied.
[root@kvm-server webvirtmgr]#
[root@kvm-server webvirtmgr]# ./manage.py createsuperuser
WARNING:root:No local_settings file found.
Username: admin
Email address:
Password:
Password (again):
Superuser created successfully.
[root@kvm-server webvirtmgr]#
手动
############
导入sqlite3 模块
[root@kvm-server src]# python
Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> exit()
[root@kvm-server src]#
或
yum -y install sqlite-devel
安装 django
pip install django
####
同步数据库
[root@kvm-server webvirtmgr]#./manage.py syncdb #会提示创建Django 连接数据库账号密码等信息
[root@kvm-server webvirtmgr]#./manage.py collectstatic #同步项目文件
[root@kvm-server webvirtmgr]#./manage.py createsuperuser #配置webvirtmgr 登录账号
配置Nginx
[root@kvm-server ~]# ll /usr/local/src/webvirtmgr/
total 72
drwxr-x--- 6 root root 114 Nov 10 00:37 conf
drwxr-x--- 2 root root 116 Nov 10 00:37 console
drwxr-x--- 3 root root 144 Nov 10 01:03 create
drwxr-x--- 4 root root 36 Nov 10 00:37 deploy
-rw-r----- 1 root root 85 Nov 10 00:37 dev-requirements.txt
drwxr-x--- 2 root root 57 Nov 10 00:37 hostdetail
drwxr-x--- 2 root root 23 Nov 10 00:37 images
drwxr-x--- 3 root root 132 Nov 10 01:03 instance
drwxr-x--- 2 root root 73 Nov 10 00:37 interfaces
drwxr-x--- 5 root root 42 Nov 10 00:37 locale
-rwxr-x--- 1 root root 253 Nov 10 00:37 manage.py
-rw-r----- 1 root root 722 Nov 10 00:37 MANIFEST.in
drwxr-x--- 2 root root 73 Nov 10 00:37 networks
-rw-r----- 1 root root 2300 Nov 10 00:37 README.rst
-rw-r----- 1 root root 149 Nov 10 00:37 requirements.txt
drwxr-x--- 2 root root 73 Nov 10 00:37 secrets
drwxr-x--- 2 root root 74 Nov 10 00:37 serverlog
drwxr-x--- 2 root root 128 Nov 10 01:03 servers
-rw-r----- 1 root root 2263 Nov 10 00:37 setup.py
drwxr-x--- 6 root root 51 Nov 10 01:05 static
drwxr-x--- 2 root root 73 Nov 10 00:37 storages
drwxr-x--- 2 root root 4096 Nov 10 00:37 templates
-rw-r----- 1 root root 580 Nov 10 00:37 Vagrantfile
drwxr-x--- 2 root root 224 Nov 10 00:37 vrtManager
drwxr-x--- 5 root root 177 Nov 10 01:03 webvirtmgr
-rw-r----- 1 root root 38912 Nov 10 01:06 webvirtmgr.sqlite3
[root@kvm-server ~]# mv /usr/local/src/webvirtmgr/ /var/www/webvirtmgr/
[root@kvm-server ~]# chown nginx.nginx -R /var/www/webvirtmgr/
[root@kvm-server ~]#
######
[root@kvm-server ~]# vim /etc/nginx/conf.d/webvirtmgr.conf
[root@kvm-server ~]# cat /etc/nginx/conf.d/webvirtmgr.conf
server {
listen 80 ;
server_name kvm.riyimei.cn;
access_log /var/log/nginx/webvirtmgr_access_log;
location /static/ {
root /var/www/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;
}
}
[root@kvm-server ~]#
[root@kvm-server ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@kvm-server ~]#
[root@kvm-server ~]# systemctl enable nginx.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@kvm-server ~]# systemctl restart nginx.service
[root@kvm-server ~]#
[root@kvm-server ~]# vim /etc/supervisord.d/webvirtmgr.ini
[root@kvm-server ~]# cat /etc/supervisord.d/webvirtmgr.ini
[program:webvirtmgr]
command=/usr/bin/python /usr/local/src/webvirtmgr/manage.py run_gunicorn -c /usr/local/src/webvirtmgr/conf/gunicorn.conf.py
directory=/usr/local/src/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[program:webvirtmgr-console]
command=/usr/bin/python /usr/local/src/webvirtmgr/console/webvirtmgr-console
directory=/usr/local/src/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
[root@kvm-server ~]#
[root@kvm-server ~]# systemctl enable supervisord.service
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
[root@kvm-server ~]# systemctl restart supervisord.service
[root@kvm-server ~]# systemctl status supervisord.service
● supervisord.service - Process Monitoring and Control Daemon
Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-11-10 01:17:41 CST; 4s ago
Process: 5407 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
Main PID: 5410 (supervisord)
Tasks: 1
CGroup: /system.slice/supervisord.service
└─5410 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
Nov 10 01:17:41 kvm-server systemd[1]: Starting Process Monitoring and Control Daemon...
Nov 10 01:17:41 kvm-server systemd[1]: Started Process Monitoring and Control Daemon.
[root@kvm-server ~]#