https://www.cnblogs.com/nulige/p/9236191.html

官网:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

检查是否支持虚拟化

  1. egrep '(vmx|svm)' --color=always /proc/cpuinfo
  1. egrep '(vmx|svm)' /proc/cpuinfo
  1. [root@kvm-server ~]# egrep '(vmx|svm)' /proc/cpuinfo
  2. 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
  3. 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
  4. 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
  5. 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
  6. [root@kvm-server ~]#

查看KVM模块
lsmod | grep kv

  1. [root@kvm-server ~]# lsmod | grep kv
  2. kvm_intel 188644 0
  3. kvm 621480 1 kvm_intel
  4. irqbypass 13503 1 kvm
  5. [root@kvm-server ~]#

添加源

  1. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  2. yum clean all
  3. yum makecache
  4. yum -y install epel-release

安装常用包

  1. 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

  1. [root@kvm-server ~]# systemctl status libvirtd
  2. [root@kvm-server ~]# systemctl status libvirtd
  3. libvirtd.service - Virtualization daemon
  4. Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
  5. Active: inactive (dead)
  6. Docs: man:libvirtd(8)
  7. https://libvirt.org
  8. [root@kvm-server ~]# systemctl enable libvirtd
  9. [root@kvm-server ~]# systemctl restart libvirtd
  10. [root@kvm-server ~]# systemctl status libvirtd
  11. libvirtd.service - Virtualization daemon
  12. Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
  13. Active: active (running) since Mon 2020-11-09 23:59:48 CST; 2s ago
  14. Docs: man:libvirtd(8)
  15. https://libvirt.org
  16. Main PID: 2369 (libvirtd)
  17. Tasks: 19 (limit: 32768)
  18. CGroup: /system.slice/libvirtd.service
  19. ├─2369 /usr/sbin/libvirtd
  20. ├─2478 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libv...
  21. └─2479 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libv...
  22. Nov 09 23:59:48 kvm-server dnsmasq[2475]: listening on virbr0(#3): 192.168.122.1
  23. Nov 09 23:59:48 kvm-server dnsmasq[2478]: started, version 2.76 cachesize 150
  24. 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
  25. Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
  26. Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: DHCP, sockets bound exclusively to interface virbr0
  27. Nov 09 23:59:48 kvm-server dnsmasq[2478]: reading /etc/resolv.conf
  28. Nov 09 23:59:48 kvm-server dnsmasq[2478]: using nameserver 114.114.114.114#53
  29. Nov 09 23:59:48 kvm-server dnsmasq[2478]: read /etc/hosts - 2 addresses
  30. Nov 09 23:59:48 kvm-server dnsmasq[2478]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
  31. Nov 09 23:59:48 kvm-server dnsmasq-dhcp[2478]: read /var/lib/libvirt/dnsmasq/default.hostsfile
  32. Hint: Some lines were ellipsized, use -l to show in full.
  33. [root@kvm-server ~]#
  1. [root@kvm-server ~]# virsh -c qemu:///system list
  2. Id Name State
  3. ----------------------------------------------------
  4. [root@kvm-server ~]#
  5. [root@kvm-server ~]# virsh --version
  6. 4.5.0
  7. [root@kvm-server ~]# virt-install --version
  8. 1.5.0
  9. [root@kvm-server ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
  10. [root@kvm-server ~]# lsmod |grep kvm
  11. kvm_intel 188644 0
  12. kvm 621480 1 kvm_intel
  13. irqbypass 13503 1 kvm
  14. [root@kvm-server ~]#

查看桥接网络

  1. [root@kvm-server ~]# brctl show
  2. bridge name bridge id STP enabled interfaces
  3. virbr0 8000.525400eb1918 yes virbr0-nic
  4. [root@kvm-server ~]#

man virt-install

  1. 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
  2. --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
  1. 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

依赖包

  1. yum install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx -y

git-hub中下载相关的webvirtmgr代码

  1. [root@kvm-server ~]# cd /usr/local/src/
  2. [root@kvm-server src]# git clone git://github.com/retspen/webvirtmgr.git
  3. Cloning into 'webvirtmgr'...
  4. remote: Enumerating objects: 5614, done.
  5. remote: Total 5614 (delta 0), reused 0 (delta 0), pack-reused 5614
  6. Receiving objects: 100% (5614/5614), 2.98 MiB | 47.00 KiB/s, done.
  7. Resolving deltas: 100% (3602/3602), done.
  8. [root@kvm-server src]# ll
  9. total 4
  10. drwxr-x--- 20 root root 4096 Nov 10 00:37 webvirtmgr
  11. [root@kvm-server src]#

临时更换pip国内源:

  1. pip install some-package -i https://mirrors.aliyun.com/pypi/simple/
  1. [root@kvm-server src]# cd webvirtmgr/
  2. [root@kvm-server webvirtmgr]# pwd
  3. /usr/local/src/webvirtmgr
  4. [root@kvm-server webvirtmgr]#
  5. [root@kvm-server webvirtmgr]# pip install some-package -i https://mirrors.aliyun.com/pypi/simple/
  6. Collecting some-package
  7. Downloading https://mirrors.aliyun.com/pypi/packages/e7/a2/d318a685319c3801db1ae0002fc8e095663a55546c62a6e30d9d0fc3289b/some-package-0.1.zip
  8. Installing collected packages: some-package
  9. Running setup.py install for some-package ... done
  10. Successfully installed some-package-0.1
  11. You are using pip version 8.1.2, however version 20.2.4 is available.
  12. You should consider upgrading via the 'pip install --upgrade pip' command.
  13. [root@kvm-server webvirtmgr]# pip install -r requirements.txt
  14. Collecting django==1.5.5 (from -r requirements.txt (line 1))
  15. Downloading https://files.pythonhosted.org/packages/38/49/93511c5d3367b6b21fc2995a0e53399721afc15e4cd6eb57be879ae13ad4/Django-1.5.5.tar.gz (8.1MB)
  16. 100% |████████████████████████████████| 8.1MB 10kB/s
  17. ######失败再次安装
  18. [root@kvm-server webvirtmgr]# pip install -r requirements.txt
  19. Collecting django==1.5.5 (from -r requirements.txt (line 1))
  20. Using cached https://files.pythonhosted.org/packages/38/49/93511c5d3367b6b21fc2995a0e53399721afc15e4cd6eb57be879ae13ad4/Django-1.5.5.tar.gz
  21. Collecting gunicorn==19.5.0 (from -r requirements.txt (line 2))
  22. Downloading https://files.pythonhosted.org/packages/f9/4e/f4076a1a57fc1e75edc0828db365cfa9005f9f6b4a51b489ae39a91eb4be/gunicorn-19.5.0-py2.py3-none-any.whl (113kB)
  23. 100% |████████████████████████████████| 122kB 81kB/s
  24. Collecting lockfile>=0.9 (from -r requirements.txt (line 5))
  25. Downloading https://files.pythonhosted.org/packages/c8/22/9460e311f340cb62d26a38c419b1381b8593b0bb6b5d1f056938b086d362/lockfile-0.12.2-py2.py3-none-any.whl
  26. Installing collected packages: django, gunicorn, lockfile
  27. Running setup.py install for django ... done
  28. Successfully installed django-1.5.5 gunicorn-19.5.0 lockfile-0.12.2
  29. You are using pip version 8.1.2, however version 20.2.4 is available.
  30. You should consider upgrading via the 'pip install --upgrade pip' command.
  31. [root@kvm-server webvirtmgr]#
  32. [root@kvm-server webvirtmgr]# ./manage.py syncdb
  33. WARNING:root:No local_settings file found.
  34. Creating tables ...
  35. Creating table auth_permission
  36. Creating table auth_group_permissions
  37. Creating table auth_group
  38. Creating table auth_user_groups
  39. Creating table auth_user_user_permissions
  40. Creating table auth_user
  41. Creating table django_content_type
  42. Creating table django_session
  43. Creating table django_site
  44. Creating table servers_compute
  45. Creating table instance_instance
  46. Creating table create_flavor
  47. You just installed Django's auth system, which means you don't have any superusers defined.
  48. Would you like to create one now? (yes/no): yes
  49. Username (leave blank to use 'root'):
  50. Email address:
  51. Password:
  52. Password (again):
  53. Superuser created successfully.
  54. Installing custom SQL ...
  55. Installing indexes ...
  56. Installed 6 object(s) from 1 fixture(s)
  57. [root@kvm-server webvirtmgr]#
  58. [root@kvm-server webvirtmgr]# ./manage.py collectstatic
  59. WARNING:root:No local_settings file found.
  60. You have requested to collect static files at the destination
  61. location as specified in your settings.
  62. This will overwrite existing files!
  63. Are you sure you want to do this?
  64. Type 'yes' to continue, or 'no' to cancel: yes
  65. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css'
  66. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/bootstrap.min.css'
  67. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/signin.css'
  68. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/table-sort.css'
  69. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/css/webvirtmgr.css'
  70. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.eot'
  71. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.svg'
  72. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.ttf'
  73. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.woff'
  74. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/asc.gif'
  75. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/bg.gif'
  76. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/desc.gif'
  77. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/img/favicon.ico'
  78. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/Chart.min.js'
  79. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/bootstrap-multiselect.js'
  80. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/bootstrap.min.js'
  81. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/infrastructure.js'
  82. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery-1.10.2.js'
  83. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery-migrate-1.2.1.js'
  84. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/jquery.tablesorter.js'
  85. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.ttf'
  86. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.woff'
  87. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/base.css'
  88. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/base64.js'
  89. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/black.css'
  90. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/blue.css'
  91. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/des.js'
  92. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/display.js'
  93. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/input.js'
  94. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/jsunzip.js'
  95. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/logo.js'
  96. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/playback.js'
  97. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/rfb.js'
  98. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/ui.js'
  99. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/util.js'
  100. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/websock.js'
  101. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/webutil.js'
  102. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/chrome-app/tcp-client.js'
  103. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/README.txt'
  104. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/WebSocketMain.swf'
  105. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/swfobject.js'
  106. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/web_socket.js'
  107. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/atKeynames.js'
  108. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/bitmap.js'
  109. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/cursor.js'
  110. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/display.js'
  111. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/enums.js'
  112. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/filexfer.js'
  113. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/inputs.js'
  114. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/jsbn.js'
  115. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/lz.js'
  116. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/main.js'
  117. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/playback.js'
  118. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/png.js'
  119. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/prng4.js'
  120. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/quic.js'
  121. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/resize.js'
  122. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/rng.js'
  123. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/rsa.js'
  124. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/sha1.js'
  125. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/simulatecursor.js'
  126. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicearraybuffer.js'
  127. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spiceconn.js'
  128. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicedataview.js'
  129. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicemsg.js'
  130. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/spicetype.js'
  131. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/ticket.js'
  132. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/utils.js'
  133. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/webm.js'
  134. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/wire.js'
  135. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/jsbn.js'
  136. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/prng4.js'
  137. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rng.js'
  138. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rsa.js'
  139. Copying '/usr/local/src/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/sha1.js'
  140. 75 static files copied.
  141. [root@kvm-server webvirtmgr]#
  142. [root@kvm-server webvirtmgr]# ./manage.py createsuperuser
  143. WARNING:root:No local_settings file found.
  144. Username: admin
  145. Email address:
  146. Password:
  147. Password (again):
  148. Superuser created successfully.
  149. [root@kvm-server webvirtmgr]#

手动
############
导入sqlite3 模块

  1. [root@kvm-server src]# python
  2. Python 2.7.5 (default, Aug 7 2019, 00:51:29)
  3. [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import sqlite3
  6. >>> exit()
  7. [root@kvm-server src]#


yum -y install sqlite-devel

安装 django

  1. pip install django
####
同步数据库
  1. [root@kvm-server webvirtmgr]#./manage.py syncdb #会提示创建Django 连接数据库账号密码等信息
  2. [root@kvm-server webvirtmgr]#./manage.py collectstatic #同步项目文件
  3. [root@kvm-server webvirtmgr]#./manage.py createsuperuser #配置webvirtmgr 登录账号

配置Nginx

  1. [root@kvm-server ~]# ll /usr/local/src/webvirtmgr/
  2. total 72
  3. drwxr-x--- 6 root root 114 Nov 10 00:37 conf
  4. drwxr-x--- 2 root root 116 Nov 10 00:37 console
  5. drwxr-x--- 3 root root 144 Nov 10 01:03 create
  6. drwxr-x--- 4 root root 36 Nov 10 00:37 deploy
  7. -rw-r----- 1 root root 85 Nov 10 00:37 dev-requirements.txt
  8. drwxr-x--- 2 root root 57 Nov 10 00:37 hostdetail
  9. drwxr-x--- 2 root root 23 Nov 10 00:37 images
  10. drwxr-x--- 3 root root 132 Nov 10 01:03 instance
  11. drwxr-x--- 2 root root 73 Nov 10 00:37 interfaces
  12. drwxr-x--- 5 root root 42 Nov 10 00:37 locale
  13. -rwxr-x--- 1 root root 253 Nov 10 00:37 manage.py
  14. -rw-r----- 1 root root 722 Nov 10 00:37 MANIFEST.in
  15. drwxr-x--- 2 root root 73 Nov 10 00:37 networks
  16. -rw-r----- 1 root root 2300 Nov 10 00:37 README.rst
  17. -rw-r----- 1 root root 149 Nov 10 00:37 requirements.txt
  18. drwxr-x--- 2 root root 73 Nov 10 00:37 secrets
  19. drwxr-x--- 2 root root 74 Nov 10 00:37 serverlog
  20. drwxr-x--- 2 root root 128 Nov 10 01:03 servers
  21. -rw-r----- 1 root root 2263 Nov 10 00:37 setup.py
  22. drwxr-x--- 6 root root 51 Nov 10 01:05 static
  23. drwxr-x--- 2 root root 73 Nov 10 00:37 storages
  24. drwxr-x--- 2 root root 4096 Nov 10 00:37 templates
  25. -rw-r----- 1 root root 580 Nov 10 00:37 Vagrantfile
  26. drwxr-x--- 2 root root 224 Nov 10 00:37 vrtManager
  27. drwxr-x--- 5 root root 177 Nov 10 01:03 webvirtmgr
  28. -rw-r----- 1 root root 38912 Nov 10 01:06 webvirtmgr.sqlite3
  29. [root@kvm-server ~]# mv /usr/local/src/webvirtmgr/ /var/www/webvirtmgr/
  30. [root@kvm-server ~]# chown nginx.nginx -R /var/www/webvirtmgr/
  31. [root@kvm-server ~]#
  32. ######
  33. [root@kvm-server ~]# vim /etc/nginx/conf.d/webvirtmgr.conf
  34. [root@kvm-server ~]# cat /etc/nginx/conf.d/webvirtmgr.conf
  35. server {
  36. listen 80 ;
  37. server_name kvm.riyimei.cn;
  38. access_log /var/log/nginx/webvirtmgr_access_log;
  39. location /static/ {
  40. root /var/www/webvirtmgr;
  41. expires max;
  42. }
  43. location / {
  44. proxy_pass http://127.0.0.1:8000;
  45. proxy_set_header X-Real-IP $remote_addr;
  46. proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
  47. proxy_set_header Host $host:$server_port;
  48. proxy_set_header X-Forwarded-Proto $scheme;
  49. proxy_connect_timeout 600;
  50. proxy_read_timeout 600;
  51. proxy_send_timeout 600;
  52. client_max_body_size 1024M;
  53. }
  54. }
  55. [root@kvm-server ~]#
  56. [root@kvm-server ~]# nginx -t
  57. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  58. nginx: configuration file /etc/nginx/nginx.conf test is successful
  59. [root@kvm-server ~]#
  60. [root@kvm-server ~]# systemctl enable nginx.service
  61. Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
  62. [root@kvm-server ~]# systemctl restart nginx.service
  63. [root@kvm-server ~]#
  1. [root@kvm-server ~]# vim /etc/supervisord.d/webvirtmgr.ini
  2. [root@kvm-server ~]# cat /etc/supervisord.d/webvirtmgr.ini
  3. [program:webvirtmgr]
  4. command=/usr/bin/python /usr/local/src/webvirtmgr/manage.py run_gunicorn -c /usr/local/src/webvirtmgr/conf/gunicorn.conf.py
  5. directory=/usr/local/src/webvirtmgr
  6. autostart=true
  7. autorestart=true
  8. logfile=/var/log/supervisor/webvirtmgr.log
  9. log_stderr=true
  10. user=nginx
  11. [program:webvirtmgr-console]
  12. command=/usr/bin/python /usr/local/src/webvirtmgr/console/webvirtmgr-console
  13. directory=/usr/local/src/webvirtmgr
  14. autostart=true
  15. autorestart=true
  16. stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
  17. redirect_stderr=true
  18. user=nginx
  19. [root@kvm-server ~]#
  1. [root@kvm-server ~]# systemctl enable supervisord.service
  2. Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
  3. [root@kvm-server ~]# systemctl restart supervisord.service
  4. [root@kvm-server ~]# systemctl status supervisord.service
  5. supervisord.service - Process Monitoring and Control Daemon
  6. Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
  7. Active: active (running) since Tue 2020-11-10 01:17:41 CST; 4s ago
  8. Process: 5407 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
  9. Main PID: 5410 (supervisord)
  10. Tasks: 1
  11. CGroup: /system.slice/supervisord.service
  12. └─5410 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
  13. Nov 10 01:17:41 kvm-server systemd[1]: Starting Process Monitoring and Control Daemon...
  14. Nov 10 01:17:41 kvm-server systemd[1]: Started Process Monitoring and Control Daemon.
  15. [root@kvm-server ~]#