美文网首页Django
运维开发环境搭建

运维开发环境搭建

作者: sknfie | 来源:发表于2024-07-29 13:35 被阅读0次

Django安装

pip install django==3.2.21 # 安装指定版本

import django
print ( django.get_version ())

pip run install django

Django中使用mysql

pip install pymysql

pip uninstall pymysql

Django中使用cors

pip install django-cors-headers

pip uninstall django-cors-headers

Django中使用resftful框架

pip install djangorestframework

pip uninstall djangorestframework

Django中使用JWT认证

pip install djangorest framework-jwt

pip uninstall djangorest framework-jwt

Django配置

pip install django == 3.1.4

pip install pymysql==0.10.0

pip install djangorestframework==3.12.2

pip install djangorestframework_jwt==1.11.0

pip install django-cors-headers==3.9.0

pymysql-1.1.0

django-cors-headers-4.1.0

djangorestframework-3.14.0

djangorestframework-jwt-1.11.0

运行

python manage.py makemigrations

python manage.py migrate

python manage.py runserver

virtualenv的安装

virtualenv的安装

pip install virtualenv

创建虚拟环境

virtualenv venv1

激活虚拟环境

source ./venv1/bin/activate #linux

.\venv1\Scripts\activate #windows

退出虚拟环境

deactivate

安装依赖包

pip install -r requirements.txt

pipenv安装:

pip3 install pipenv -i https://repo.privatexx.com/repository/pypi/simple

ln -s /usr/local/python3/bin/pipenv /usr/bin/pipenv

pipenv --version

前端配置:

npm config set registry https://repo.privatexx.com/repository/npm-group/

yarn config set registry https://repo.privatexx.com/repository/npm-group/

yarn config delete proxy npm

node -v

npm install -g npm@^8

npm install -g npm@9.8.1

版本冲突:

npm view vuex versions --json

npm install vuex@3.6.2 --save

npm install vue-router vue-resource --S --legacy-peer-deps

部署到nginx

yum install nginx

yarn build

cp dist/* /usr/share/nginx/html -r

cd /etc/nginx/conf.d/

vi ftopsvue.conf

server {

    listen 8000;

    server_name 10.54.167.133;



    location / {

        root /usr/share/nginx/html;

        index index.html index.htm;

        try_files $uri $uri/ /index.html;

    }



    location /api/ {

        proxy_pass http://localhost:5000;

        proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header X-Forwarded-Proto $scheme;



        add_header 'Access-Control-Allow-Origin' '*' always;

        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;

        add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;

    }



}

systemctl reload nginx

systemctl status nginx

相关文章

网友评论

    本文标题:运维开发环境搭建

    本文链接:https://www.haomeiwen.com/subject/wekwhjtx.html