Very strange behaviour linux user and permissions


Hopefully someone can help me out asap, my site isn`t working ATM due to an issue.

I changed the apache MPM and for that I needed to change virtualmin to have it run as virtualserver owner (was the only option left). I did that, and now the virtual server runs as virtual server owner.

So I did whoami check in PHP and saw the user which was the virtualserver owner.
Unfortunately, the webshop did not work, I couldn`t login and sessions where not stored.

So I thought, must be permissions. Server runs as UserX but permissions where still www-data. So I changed all files and folder permissions to chown UserX. Then I changed apache run user and I changed suexec UserGroup.

Restart apache and it seemed to work, but just for a couple of minutes. After that, session where not stored anymore.

So here is where the strange behaviour started happening. I have chowned a dir to 777 and user + group UserX. Then I SFTP with UserX as user and I try uploading a file, does not work. It does upload, but the file is empty. Then I checked error log, session folder, etc. Everything empty files.

What`s happening? Why are empty files created? Where did I go wrong in the above steps?

Im eager to learn more and obviously Im missing something (or a couple of things). Hopefully someone can help me out on short notice since it has killed my shop :frowning:

Thanks a lot!


Well, it’s difficult to say what exactly is occurring… how did you go about changing how PHP is being executed?

You mentioned changing the Apache MPM and config settings for that, however, all you’d actually need to do is to go into Server Configuration -> Website Options, and there, change the PHP Execution Mode to your preferred mode.

You don’t need to change the PHP MPM, or edit any Apache config options.

FCGID is the default PHP Execution Mode, and does run PHP as the Virtual Server owner. CGI does the same. If it’s set to mod_php though that would cause PHP to be run as the Apache user.

Just to make sure all permissions are correct, you may want to go into Limits and Validation -> Validate Virtual Servers -> Fix Permissions, and there, have it correct the permissions for this particular domain. It’s possible that a file or directory somewhere has a permission issue.

Lastly, you may also want to check the Apache error logs for the domain, which are located in $HOME/logs/error_log. That may contain some clues as to what the issue is.


Hi Eric,

Thanks for your quick reply. Unfortunately fixing permissions didn`t help… Everytime I upload something the file gets emptied so an empty file is created on the server.

Does changing PHP execution mode to CGI also change the Apache MPM? I think I have made it way too complicated for myself… I tried changing to event MPM in order to have better results on high visitor load website.

The error log does not say anything unfortunately.

What would you suggest to fix this? Should I consider reinstalling stuff?


Is there any chance the domain has reached it’s quota? That’s another explanation of the symptoms you’re seeing.

And no, switching between FCGID, CGI, and mod_php doesn’t change the Apache MPM.

However, you should also be able to change the Apache MPM – it’s just not necessary for that to work.


Hi Eric,

Super strange… Quota doesnt seem to be the issue.. Also, I can create files with content when Im root (via SSH) but just not via de virtualserver user.

At the moment I tried a couple of things, but I`m now getting this error
Not Found
The requested URL /cgi-bin/php5.cgi/index.php was not found on this server.

It`s not really getting better, I think I need to restore a backup.


What do you see when trying to create files as the Virtual Server owner when logged in via SSH?


YES, Eric, you`re a lifesaver.

Actually, it was diskquota… I was looking at it totally wrong. I changed to the virtualserver owner user and I created a file, which nicely dropped an error ‘disk quota exceeded’. I was just missing one simple quota setting in Virtualmin, which I didn`t know was there.

Thank you so much, everything is up&running again :slight_smile:


Great, I’m glad you were able to get it working!