###1、安裝MySQLpython
mysql> create database webvirtmgr default character set utf8; mysql> grant all on webvirtmgr.* to webvirtmgr@"127.0.0.1" identified by "webvirtmgr";
###2、部署webvirtmgr 參考官網:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgrmysql
shell> wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo shell> yum -y install git python-pip libvirt-python libxml2-python MySQL-python cyrus-sasl-md5 shell> pip install numpy==1.16.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com shell> pip install websockify==0.8.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
shell> cd /export/home/webroot/ shell> git clone git://github.com/retspen/webvirtmgr.git shell> cd webvirtmgr shell> pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com # 如下爲定製化二次開發功能組件支持 shell> pip install fabric==2.4.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com # 解壓二次開發的壓縮包,覆蓋/export/home/webroot/webvirtmgr目錄下全部文件。 shell> cd /export/home/webroot shell> wget http://dlsw.91donkey.com/software/source/webvirtmgr/webvirtmgr_custom_development.tgz shell> mv webvirtmgr webvirtmgr.default shell> tar zxf webvirtmgr_custom_development.tgz
# 編輯/export/home/webroot/webvirtmgr/webvirmgr/settings.py # 將sqlite3改成mysql數據庫 # # 原信息 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(os.path.dirname(__file__), '..', 'webvirtmgr.sqlite3'), # The following settings are not used with sqlite3: 'USER': '', 'PASSWORD': '', 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 'PORT': '', # Set to empty string for default. } } # 替換爲 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'webvirtmgr', 'USER': 'webvirtmgr', 'PASSWORD': 'webvirtmgr', 'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 'PORT': '3306', # Set to empty string for default. } } shell> cd /export/home/webvirtmgr shell> ./manage.py syncdb Would you like to create one now? (yes/no): yes Username (Leave blank to use 'root'): root E-mail address: ma.yulong@aliyun.com Password: xxxxxx Password (again): xxxxxx Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 6 object(s) from 1 fixture(s) shell> ./manage.py collectstatic Type 'yes' to continue, or 'no' to cancel: yes shell> chown -R nobody. /export/home/webroot/
shell> ./manage.py createsuperuser
###3、安裝Nginxnginx
# 在nginx配置中增長vhost信息 server { server_name 10.20.73.74; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; } }
###4、安裝Supervisorgit
shell> pip install supervisor -i http://mirrors.aliyun.com/pypi/simple/--trusted-host mirrors.aliyun.com shell> mkdir /opt/supervisor && cd /opt/supervisor shell> echo_supervisord_conf > supervisord.conf shell> mv supervisord.conf supervisord.conf.default shell> mkdir /opt/supervisor/conf.d shell> mkdir /opt/supervisor/log
配置supervisord.confgithub
shell> cat >> supervisord.conf << EOF [supervisord] logfile=/opt/supervisor/supervisord.log logfile_maxbytes=1024MB logfile_backups=10 loglevel=info pidfile=/opt/supervisor/supervisord.pid nodaemon=false minfds=1024 minprocs=200 directory=/opt/supervisor nocleanup=true childlogdir=/opt/supervisor/log [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=http://10.20.73.74:9998 [inet_http_server] port = 10.20.73.74:9998 username = 91donkey password = 123456 [include] files = /opt/supervisor/conf.d/*.conf EOF
配置conf.d/webvirtmgr.confweb
shell> cat >> conf.d/webvirtmgr.conf << EOF [program:webvirtmgr] command=/usr/bin/python /export/home/webroot/webvirtmgr/manage.py run_gunicorn -c /export/home/webroot/webvirtmgr/conf/gunicorn.conf.py directory=/export/home/webroot/webvirtmgr autostart=true autorestart=true logfile=/opt/supervisor/log/webvirtmgr.log log_stderr=true user=root [program:webvirtmgr-console] command=/usr/bin/python /export/home/webroot/webvirtmgr/console/webvirtmgr-console directory=/export/home/webroot/webvirtmgr autostart=true autorestart=true stdout_logfile=/opt/supervisor/log/webvirtmgr-console.log redirect_stderr=true user=root EOF
啓動supervisor服務sql
shell> /usr/bin/python /usr/bin/supervisord -c /opt/supervisor/supervisord.conf