私はDjangoプロジェクトに取り組んでおり、ApacheをWebサーバーとして使用しています。
python manage.py runserver
しかし、Apache 経由でアプリケーションを実行しているときに、プロジェクト ディレクトリ外の指定されたパスに Python アプリのログを書き込むことができません。
プロジェクトディレクトリ/home/ubuntu/saas-DocumentProcessing
ログファイルは
/home/ubuntu/log/SaasAap/SaasAap.log
そして/home/ubuntu/log/error/error.log
私の000-default.conf
コンテンツ
<VirtualHost *:8000>
ServerAdmin [email protected]
ServerName my_ip
ServerAlias my_ip
DocumentRoot /home/ubuntu/saas-DocumentProcessing/
WSGIScriptAlias / /home/ubuntu/saas-DocumentProcessing/src/wsgi.py
Alias /static/ /home/ubuntu/saas-DocumentProcessing/static/
ErrorLog /home/ubuntu/log/error.log
CustomLog /home/ubuntu/log/custom.log combined
<Location "/static/">
Options -Indexes
AllowOverride All
Require all granted
</Location>
<Location "/">
AllowOverride All
Require all granted
</Location>
<Directory /home/ubuntu/saas-DocumentProcessing/static>
Order allow,deny
Allow from all
</Directory>
<Directory /home/ubuntu/log>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess saas-DocumentProcessing python-path=/home/ubuntu/
saas-DocumentProcessing python-home=/home/ubuntu/saas-DocumentProcessing/ve
nv
WSGIProcessGroup saas-DocumentProcessing
</VirtualHost>
答え1
ステップ 1: Apache がどのユーザーとして実行されているかを確認します。
ps aux | egrep '(apache|httpd)'
次に、ログを書き込むディレクトリのファイル所有権と権限を確認します。このディレクトリ (および子ディレクトリ) の所有者を Apache と一致するように変更するか、ファイル権限を変更してこのディレクトリへの書き込みを許可します。
最善の解決策は所有者を変更することです。
sudo chown -R <user_from_above> /home/ubuntu/log
安全ではない方法は、権限を変更することです。
sudo chmod 777 /home/ubuntu/log
sudo chmod 777 /home/ubuntu/log/SaasAap