저는 Django 프로젝트를 진행 중이며 Apache를 웹 서버로 사용하고 있습니다. 모든 것이 잘 작동하고 있습니다.
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