You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NGINX & UWSGI启动服务器时出现权限拒绝问题

Fixing uWSGI "Permission denied" for Log File on Raspberry Pi 3

Hey there, let's tackle that permission error you're hitting when trying to start uWSGI. The root issue here is that your pi user doesn't have write access to the /var/log/uwsgi directory or the specific log file. Here's how to fix it step by step:

Step 1: Verify the log directory's permissions

First, check who owns the /var/log/uwsgi directory and what permissions it has. Run this command:

ls -ld /var/log/uwsgi

This will show you the owner (like root:root) and permission settings (like drwxr-xr-x). If the pi user isn't the owner or doesn't have write permissions, that's the core problem.

Step 2: Create the log directory (if it doesn't exist)

If the /var/log/uwsgi directory doesn't exist at all, create it first with sudo:

sudo mkdir -p /var/log/uwsgi

Step 3: Adjust permissions to let your user write to the directory

You have two main options here, depending on how you plan to run uWSGI:

Option A: Give the pi user ownership

If you're running uWSGI as the pi user (which you are, since you're in your virtual environment), set the directory owner to pi:

sudo chown pi:pi /var/log/uwsgi
# Then set proper directory permissions to ensure access
sudo chmod 755 /var/log/uwsgi

Option B: Use the web server user (for production)

If you're setting this up for production and will run uWSGI as the www-data user (common for Nginx/Apache setups), set ownership to that user instead:

sudo chown www-data:www-data /var/log/uwsgi
sudo chmod 755 /var/log/uwsgi

Step 4: Test the uWSGI command again

Once permissions are set, go back to your virtual environment and run the original command again:

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

If you just need to test quickly, you can run uWSGI with sudo to bypass permissions temporarily:

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

Note: Running uWSGI as root carries security risks, so only use this for testing and stick to the permission adjustment method for production setups.

Final check

Double-check your lab_app_uwsgi.ini file to make sure the log path is spelled correctly. The relevant line should look something like:

logto = /var/log/uwsgi/lab_app_uwsgi.log

内容的提问来源于stack exchange,提问作者S.Q

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:31:19