我將我的 django 應用程式的 beta 版本部署到 DigitalOcean,并使用 Apache 和 WSGI 為其提供服務。
一切正常,包括靜態檔案和“獲取”媒體檔案(我將其直接保存到資料庫),除了上傳檔案。它顯示“權限被拒絕”錯誤,完整目錄如“/home/test/project/media/test.jpeg”。
我像這樣配置了httpd-vhosts。
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
WSGIScriptAlias / /home/test/project/project/wsgi.py
WSGIDaemonProcess example.com python-home=/home/test/project/.venv python-path=/home/test/project/project
WSGIProcessGroup example.com
Alias /static/ /home/test/project/frontend/build/static/ # react build dir
<Directory /home/test/project/frontend/build/static>
Require all granted
</Directory>
Alias /uploadImg/ /home/test/project/media/
<Directory /home/test/project/media>
Require all granted
</Directory>
<Directory /home/test/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
所以 httpd 與守護行程一起運行,我的目錄 'media' 歸根目錄 755 所有。但是目錄 'media' 是位于 '/home/test/' 的符號鏈接目錄
我做了很多嘗試來修復它,但沒有任何效果.. 感謝所有回復
uj5u.com熱心網友回復:
我自己解決了。我的問題是關于“誰運行 apache 行程”和“誰擁有目錄”。它應該是具有寫入權限的同一用戶或組。希望對此有問題的人有所幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/465446.html
