Chope If you are using Nginx, you can run:
sudo useradd "php_flarum" --home-dir "/var/www/flarum" --system --shell /bin/false
sudo gpasswd -a "www-data" "php_flarum"
sudo gpasswd -a "php_flarum" "www-data"
Make sure to restart php-fpm and nginx after running these commands. Let me know if these commands resolve it
As you can see, php_flarum is a user but also has a group with the same name.
Chope Thought the user is always the one I am logged with which the user variable $user represents.
Correct. But linux transparently does a lot of privilege separation with services. Consider this:
The root user has access to everything. Only root may bind ports less than 1024.
Nginx binds to port 80 which requires root access.
However, you don't want nginx running as root. If it's compromised, your server is compromised.
Nginx binds to port 80 as root, then drops to a unprivileged user, often set as www-data
My script follows this approach. It uses its own user that has access to naught but critical portions of the flarum installs.