新增 Service:Django
39
Service%EF%BC%9ADjango.md
Normal file
39
Service%EF%BC%9ADjango.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# 安裝 Django
|
||||
|
||||
```bash
|
||||
pip3 install Django
|
||||
```
|
||||
|
||||
# 建立專案
|
||||
|
||||
```bash
|
||||
mkdir djangotutorial && django-admin startproject mysite djangotutorial
|
||||
```
|
||||
|
||||
# 啟動專案
|
||||
|
||||
在 setting.py 將主機位置加入 ALLOWED_HOSTS
|
||||
|
||||
```python3
|
||||
ALLOWED_HOSTS = [ "192.168.30.107" ]
|
||||
```
|
||||
|
||||
開發模式
|
||||
|
||||
```bash
|
||||
python3 manage.py runserver 0.0.0.0:8000
|
||||
```
|
||||
|
||||
生產模式(wsgi)
|
||||
|
||||
使用 gunicorn
|
||||
|
||||
```bash
|
||||
pip3 install gunicorn
|
||||
```
|
||||
|
||||
透過 gunicorn 啟動
|
||||
|
||||
```bash
|
||||
gunicorn --bind 0.0.0.0:8000 mysite.wsgi:application
|
||||
```
|
||||
Reference in New Issue
Block a user