Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

HungryBus's avatar

Bet way to set up PHP user while running Laravel

What user PHP should run as?

Right now, on my Apache2 + PHP8 (FPM) users are as follows: Apache runs as www-data, PHP runs as me (the one I am logging into the Debian server with).

I don't think this is a very good practice, since this user also is a sudoer, also I don't really want PHP to run as www-data (as others state in other forums, it is insecure).

So, what user PHP should be running as?

0 likes
6 replies
Sinnbeck's avatar

Why is www-data in sudo? Pretty sure that is not default :)

1 like
HungryBus's avatar

@Sinnbeck www-data is not in sudo. PHP runs not as www-data, but as my user (let's say hungrybus), thus creates files as hungrybus:www-data. Hungrybus is in sudo, not www-data

Sinnbeck's avatar

@HungryBus You can create a new "dummy" user to do the pulling and running of the webserver. Thats what I normally do :)

1 like
HungryBus's avatar

@Tray2 Still says that PHP shoud run as www-data also. But should it, since www-data is a server-wide user :thinking:

Please or to participate in this conversation.