操作步骤如下
# 查看已安装Python版本
pyenv versions
* system (set by /opt/pyenv/version)
3.7.0
# 如已安装,可忽略
pyenv install 3.7.0
# 创建并进入运行目录
mkdir domain-admin && cd domain-admin
# 创建虚拟环境
pyenv virtualenv 3.7.0 domain-admin
# 设置该目录的Python版本
echo 'domain-admin' > .python-version
# 查看当前Python版本
python --version
Python 3.7.0
# 升级pip
pip install --upgrade pip
# 安装domain-admin
pip install domain-admin
# 查看未使用的端口
lsof -i:5009
# 启动
gunicorn --bind '127.0.0.1:5009' 'domain_admin.main:app'
domain-admin.ini
[program: domain-admin]
directory=/opt/domain-admin
command=/opt/pyenv/versions/domain-admin/bin/gunicorn --bind '127.0.0.1:5009' 'domain_admin.main:app'
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/opt/domain-admin/logs/supervisor.log
domain-admin.conf
server
{
listen 5008;
server_name localhost;
error_log /usr/local/nginx/logs/domain-admin_error.log;
access_log /usr/local/nginx/logs/domain-admin_access.log;
# 代理服务器
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:5009;
}
}
如果是使用阿里云,则需要看安全组端口是否已开放