我正在处理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 abc@xyz.com
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>
发布于 2018-08-28 13:51:42
步骤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
https://serverfault.com/questions/928332
复制相似问题