Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(13)Permission denied: mod_wsgi Unable to connect to WSGI

Tags:

django

wsgi

I'm trying to run django 1.3.1 on new vps server (CentOS 6).
Right now I'm getting this error:

(13)Permission denied: mod_wsgi (pid=7159): Unable to connect to WSGI daemon process 'somodinteriors:80' on '/etc/httpd/logs/wsgi.7152.0.1.sock' after multiple attempts.

I read how to fix it by adding WSGISocketPrefix (you can reed about it here)

This is my config file:

#Alias /robots.txt /var/www/vhosts/domain.co.uk/httpdocs/robots.txt
#Alias /favicon.ico /var/www/vhosts/domain.co.uk/httpdocs/favicon.ico

#Alias /static/ /var/www/vhosts/domain.co.uk/httpdocs/
#Alias /media/ /var/www/vhosts/domain.co.uk/httpdocs/media/

#WSGIScriptAlias / /var/www/vhosts/domain.co.uk/sites/somod/apache/django.wsgi

#<Directory /var/www/vhosts/domain.co.uk>
#    Order allow,deny
#    Allow from all
#</Directory>

#<VirtualHost *:80>
  ServerName domain.co.uk

  LogLevel debug
  ErrorLog /var/www/vhosts/domain.co.uk/logs/error.log
  CustomLog /var/www/vhosts/domain.co.uk/logs/access.log combinedio

  HostnameLookups Off

  UseCanonicalName On

  WSGIScriptAlias / /var/www/vhosts/domain.co.uk/sites/somod/apache/django.wsgi
  WSGIDaemonProcess somodinteriors:80 user=somod group=psaserv processes=1 threads=1
  WSGIProcessGroup somodinteriors:80
#  WSGIPythonPath /var/www/vhosts/domain.co.uk
  WSGISocketPrefix /var/run/wsgi

  Alias /robots.txt /var/www/vhosts/domain.co.uk/sites/templates/robots.txt
  Alias /favicon.ico /var/www/vhosts/domain.co.uk/sites/media/favicon.ico

  <Directory /var/www/vhosts/domain.co.uk/httpdocs>
    AllowOverride None
    Options -ExecCGI -Includes -FollowSymLinks -Indexes
    Order allow,deny
    Allow from all
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
  </Directory>

  <Directory /var/www/vhosts/domain.co.uk/sites>
    AllowOverride None
    Options +ExecCGI -Includes +FollowSymLinks -Indexes
    Order allow,deny
    Allow from all
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
  </Directory>

  Alias /media /var/www/chost/domain.co.uk/media
  <Location /media/>
    SetHandler None
  </Location>
#</VirtualHost>

When I add WSGISocketPrefix /var/run/wsgi to my config file, i get this error when i restart apache:

Syntax error on line 29 of /var/www/vhosts/domain.co.uk/conf/vhost.conf:
WSGISocketPrefix cannot occur within <VirtualHost> section

This folder exist:

drwxr-xr-x. 2 root      root      4096 May 29 09:36 wsgi

On website i get 503 error.

Where should i put WSGISocketPrefix /var/run/wsgi?

like image 271
miszczu Avatar asked May 29 '12 10:05

miszczu


1 Answers

Stick it outside of the VirtualHost at global scope in Apache configuration.

The documentation at:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGISocketPrefix

says that context is server config and not virtual host.

like image 52
Graham Dumpleton Avatar answered Sep 26 '22 12:09

Graham Dumpleton