Django mod_wsgi apache

左心房为你撑大大i 提交于 2019-12-05 06:20:58

This issue is documented in:

http://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets

The solutions given by others of changing permissions are wrong.

The correct solution is to change where the socket files are kept to a location where Apache user can read them.

On systems which protect logs directory, they sometimes have a system in place to set back those permissions when you mess with them. As a result any change may only be temporary.

I have wrote this script to handle wsgi socket permission problem on apache2-mpm-itk

#!/bin/sh
# This script will fix apache wsgi socket permissions
# By default use standard socket location /var/run/apache2/wsgi
# 
# You have to add this script after success execute of start|restart|reload 
# commands in next files:
#   /usr/sbin/apache2ctrl
#   /etc/init.d/apache2

WSGISocketPrefix="/var/run/apache2/wsgi"

if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

echo "Wait for other processes to start"
sleep 1
echo "Change wsgi socket permissions"
chmod 0766 ${WSGISocketPrefix}.*

The user that is running the apache process doesn't seem to have permission to read/write from the specified location.

That is usually approached by setting the WSGIDaemonProcess and WSGIProcessGroup directives in the VirtualHost conf.

WSGIDaemonProcess process-name user=user group=group threads=10 python-path=vitrual-env-path
WSGIProcessGroup process-group

You can also alternatively (unless there aren't any other permission/group problems.) just add the relevant path read/write accesses to the user running the apache process.

chmod [apache-user]+rw /etc/httpd/logs/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!