|
@@ -64,3 +64,62 @@ pip3 install mysqlclient
|
|
|
- 权限满足
|
|
|
- 模式正确
|
|
|
|
|
|
+## 部署
|
|
|
+参考地址:https://www.dusaiphoto.com/article/71/
|
|
|
+
|
|
|
+ssl授权证书(free):https://certbot.eff.org/#ubuntutyakkety-nginx
|
|
|
+
|
|
|
+### 生产环境依赖
|
|
|
+- mysql:latest
|
|
|
+- django:4.x
|
|
|
+- nginx:latest
|
|
|
+
|
|
|
+### nginx 配置
|
|
|
+```
|
|
|
+server {
|
|
|
+ # listen [::]:80;
|
|
|
+ server_name www.suzuran.fun;
|
|
|
+ root /usr/share/nginx/html;
|
|
|
+
|
|
|
+ # Load configuration files for the default server block.
|
|
|
+ include /etc/nginx/default.d/*.conf;
|
|
|
+
|
|
|
+ location / {
|
|
|
+ proxy_pass http://127.0.0.1:8000; # 转发规则
|
|
|
+ proxy_set_header Host $proxy_host; # 修改转发请求头,让8080端口的应用可以受到真实的请求
|
|
|
+ proxy_set_header X-Real-IP $remote_addr;
|
|
|
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
+ }
|
|
|
+
|
|
|
+ error_page 404 /404.html;
|
|
|
+ location = /40x.html {
|
|
|
+ }
|
|
|
+
|
|
|
+ error_page 500 502 503 504 /50x.html;
|
|
|
+ location = /50x.html {
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 项目依赖
|
|
|
+
|
|
|
+#### 配置依赖项
|
|
|
+pip freeze > requirements.txt
|
|
|
+
|
|
|
+#### 省级pip3
|
|
|
+pip3 install --upgrade pip
|
|
|
+
|
|
|
+#### 安装库
|
|
|
+pip3 install -r requirements.txt
|
|
|
+
|
|
|
+- 安装依赖过程中会提示版本不对,就把版本号改一下
|
|
|
+- 安装mysqlclient会保一些问题:安装mysqlclient提示mysql_config not found问题:https://www.cnblogs.com/yoyoketang/p/12131101.html
|
|
|
+
|
|
|
+#### 收集静态资源
|
|
|
+python3 manage.py collectstatic
|
|
|
+
|
|
|
+#### 数据库迁移
|
|
|
+python3 manage.py migrate
|
|
|
+
|
|
|
+### 启动(保存后台运行)
|
|
|
+gunicorn admin_site.wsgi:application -D
|