简体   繁体   English

Django:使用mod_wsgi创建的SOCK文件的权限错误

[英]Django: Wrong permissions for created SOCK file using mod_wsgi

I have a Django app running on my server using Apache2 and mod_wsgi. 我有一个使用Apache2和mod_wsgi在服务器上运行的Django应用。 I also having WSGI running in daemon mode. 我还让WSGI在守护程序模式下运行。 Due to this, I have a small issue that occurs every time I restart my apache2 service. 因此,每次重新启动apache2服务时,我都会遇到一个小问题。

A new sock file is created in /var/run/ which isn't the issue itself, but due to this, the new file is being created by root and given the owner www-data, my user who is serving the files is not the owner. /var/run/创建了一个新的sock文件,这本身不是问题,但是由于这个原因,新文件是由root创建的,并且给定所有者www-data,因此提供文件的用户不是主人。

My Question : 我的问题

How do I make it so that the new sock file being created is created with user as the owner and www-data as the group? 我如何做到这一点,以便以用户作为所有者并以www-data作为组来创建正在创建的新袜子文件?

As per @GrahamDumpleton 's help, I was able to solve this issue. 根据@GrahamDumpleton的帮助,我能够解决此问题。

Problem 问题

Using the wrong wsgi install ( libapache2-mod-wsgi ) which caused issues when trying to run WSGIDaemonMode inside my apache conf file. 使用错误的wsgi安装( libapache2-mod-wsgi ),这会在尝试在我的apache conf文件中运行WSGIDaemonMode时引起问题。 I was unable to use the socket-user=user option so that I did not receive a Permission denied problem when a new sock file was created upon service restart. 我无法使用socket-user=user选项,因此在服务重新启动时创建新的袜子文件时,我没有收到Permission denied问题。

Solution

For me, I did a fresh install of Debian 8 on my server since I was messing around a lot in my files trying to solve the issue, so I felt this was for the best. 对于我来说,我在服务器上进行了Debian 8的全新安装,因为我在尝试解决该问题时经常在文件中乱七八糟,所以我觉得这是最好的。 Upon a fresh install, using pip install mod_wsgi was able to work ( would not work before my fresh install, even after installing python 2.7.13 ) -- weird, I know... 全新安装后,使用pip install mod_wsgi可以工作( 即使重新安装python 2.7.13之后,在我的全新安装之前也无法工作 )-很奇怪,我知道...

Since I had mod_wsgi installed properly, I was able to use the socket-user=user option to solve my problem. 由于正确安装了mod_wsgi ,因此我可以使用socket-user=user选项解决问题。

Documentation for mod_wsgi mod_wsgi的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM