Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uwsgi socket permissions

Tags:

uwsgi

I'm running into some permission issues with uwsgi running on Ubuntu 12. Here is my ini file:

[uwsgi]
project = djangorpoject
base_dir = /home/mysite/mysite.com

uid = www-data
gid = www-data
plugins = http,python

processes = 4
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
max-requests =  2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
no-orphans = True
#vacuum = True
master = True

logto = /var/log/uwsgi/%n.log
#daemonize = /var/log/uwsgi/%n.log
#catch-exceptions
disable-logging

virtualenv = %(base_dir)/venv
chdir = %(base_dir)
module = %(project).wsgi:application

socket = /run/uwsgi/%n.sock
chmod-socket = 666
chown-socket = www-data:www-data

As you can see, I am running chmod and chown on the socket file. When I attempt to load my site, I am getting the following error:

bind(): Permission denied [socket.c line 107]

This goes away if I run

sudo chown -R www-data:www-data /run/uwsgi

But this doesn't persist when I reboot my server. I am assuming this is because uwsgi is recreating the folder on boot? Is there any way to permanently apply the permissions to socket?

like image 876
Hanpan Avatar asked Oct 08 '12 09:10

Hanpan


People also ask

What is socket in uWSGI?

HTTP socketsThe http-socket <bind> option will make uWSGI natively speak HTTP. If your web server does not support the uwsgi protocol but is able to speak to upstream HTTP proxies, or if you are using a service like Webfaction or Heroku to host your application, you can use http-socket .

What is chmod socket?

Chmod socket. This option may be set with -C from the command line. UNIX sockets are filesystem objects that obey UNIX permissions like any other filesystem object. You can set the UNIX sockets' permissions with this option if your webserver would otherwise have no access to the uWSGI socket.

Where is uWSGI config?

Configuration. Web applications served by uWSGI are configured in /etc/uwsgi/ , where each of them requires its own configuration file (ini-style). Details can be found in the uWSGI documentation. Alternatively, you can run uWSGI in Emperor mode (configured in /etc/uwsgi/emperor.


1 Answers

/run is a tmpfs which means it is not persistent across reboots. Create a directory /var/uwsgi instead which will be persistent.

like image 57
Rob Wouters Avatar answered Jan 04 '23 14:01

Rob Wouters