Default nginx runs on the user
www-data of something alike.
You can change it. Be sure that you are aware of the security risks!
Don’t change it to a user that has access to
sudo (like a pi user)!
/etc/nginx/nginx.conf on line #1 change the user.
#user www-data; user deployment;
And change the user for php-fpm (If you’re using php-fpm ?)
Create a file in
/etc/php/7.4/fpm/pool.d/ (check the php version)
I suggest something like
zzz-custom-user.conf so it’s loaded last. To that file add.
user = deployment group = deployment listen.owner = deployment listen.group = deployment
Next reload everything, agian check php version.
sudo nginx -t && sudo service php7.4-fpm restart && sudo service nginx restart
Finally change the owner of the webfiles
sudo chown pi:pi /var/www/ -R