S.Q
S.Q

Reputation: 155

NGINX & UWSGI - Permission Denied When Trying To Start Server

I am trying to make the raspberry pi 3 into a full stack web developement server, I am folloiwng this guide here and on Step 4.16 page 53, it says to type this command

 >uwsgi —ini /var/www/lab_app/lab_app_uwsgi.ini

but when I try this command, I get the error below:

(venv)pi@raspberrypi:/var/www/lab_app $ uwsgi --ini /var/www/lab_app/lab_app_uwsgi.ini

[uWSGI] getting INI configuration from /var/www/lab_app/lab_app_uwsgi.ini
open("/var/log/uwsgi/lab_app_uwsgi.log"): Permission denied [core/logging.c line 288]

I know this is probably related to the groups/users permissions but I'm not exactly sure how I would go about adding or creating a user to have the permissions to start this daemon. I am currently trying to google possible answers but would appreciate if someone could point me in the right direction.

Please also find the bellow nginx.conf & uwsgi.ini files located in the directory /var/www/lab_app/, Thanks in advance!

**lab_app_nginx.conf**

server {
listen  80;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location /static {
        root /var/www/lab_app/;
 }
location / { try_files $uri @labapp; }
location @labapp {
include uwsgi_params;
uwsgi_pass unix:/temp/labapp.sock;
 }
}

**lab_app_uwsgi.ini**

uid = www-data
gid = www-data
#application's base folder
base = /var/www/lab_app
#pytyhon module to import
app = hello
module = %(app)
home = %(base)/venv
pythonpath = %(base)
#sock file's location
socket = /temp/labapp.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the modue import at line #6
callable = app
#location of log files
logto = /var/log/uwsgi/%n.log

Upvotes: 1

Views: 2670

Answers (2)

Frank AK
Frank AK

Reputation: 1781

try to run your server with super-user

sudo uwsgi --ini /var/www/lab_app/lab_app_uwsgi.ini

Upvotes: 0

david
david

Reputation: 633

This line of the configuration states where the logfile should be stored:

logto = /var/log/uwsgi/%n.log

And the process seems to be running as www-data:

uid = www-data

Therefore I'd check the user/group of /var/log/uwsgi, does www-data have write permissions there? Does the directory exist?

The www-data user probably exists already, it should have been created when you installed nginx. If not you can use useradd to add users. Permissions can be changed with chmod, ownership can be changed with chown.

Upvotes: 2

Related Questions