|
|
行 68: |
行 68: |
| === model.py === | | === model.py === |
| *<code>models.DateField</code>儲存日期,<code>models.DateTimeField</code>儲存日期時間。參考:[https://docs.djangoproject.com/en/4.1/ref/models/fields/ Model field reference]。 | | *<code>models.DateField</code>儲存日期,<code>models.DateTimeField</code>儲存日期時間。參考:[https://docs.djangoproject.com/en/4.1/ref/models/fields/ Model field reference]。 |
|
| |
| == 伺服器類設定 ==
| |
|
| |
| ===設定Gunicorn(這可能沒有用)===
| |
| /etc/systemd/system/gunicorn.service
| |
| <pre>
| |
|
| |
| Group=www-data
| |
| WorkingDirectory=/root/lianlok
| |
| ExecStart=/usr/local/bin/gunicorn(或其他絕對路徑) --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock lianlok.wsgi:application
| |
| [Install]
| |
| WantedBy=multi-user.target
| |
| </pre>
| |
|
| |
| ===設定 nginx===
| |
|
| |
| site-available 裏面的 test 設定檔為:
| |
|
| |
| 前提要先 ./manage.py runserver 8080。
| |
| <pre>
| |
| server {
| |
| listen 80;
| |
| server_name 127.0.0.1;
| |
|
| |
| # https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
| |
| # location /static/ { # STATIC_URL
| |
| # alias /home/www/example.com/static/; # STATIC_ROOT
| |
| # }
| |
|
| |
| access_log /root/log/lianlok-access.log;
| |
| error_log /root/log/lianlok-error.log;
| |
|
| |
| location / {
| |
| proxy_set_header Host $host;
| |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
| |
| proxy_set_header X-Scheme $scheme;
| |
| proxy_pass http://127.0.0.1:8080;
| |
| }
| |
| }
| |
| </pre>
| |
|
| |
|
| ==setting.py 使用 SQLite== | | ==setting.py 使用 SQLite== |