Website Files Uploaded Through Virtualmin Sometimes Get Incorrect Ownership and Become Inaccessible

SYSTEM INFORMATION
OS type and version Ubuntu 24.04 LTS
Webmin version 2.303

Hi All,

I am having a strange issue with one of my websites hosted on Virtualmin where newly uploaded or updated website files sometimes end up with incorrect ownership or permissions, causing the website to stop being able to access those files correctly. The problem does not affect every file or every upload, which makes it difficult to identify a consistent pattern. When I initially upload or update files, the operation appears to complete successfully and the files are visible in the expected website directory, but some of those files later behave as though the web server does not have permission to read them. This can result in certain pages or resources not being served correctly even though the files are physically present on the server. If I manually correct the ownership or permissions of the affected files, the website immediately starts working with those files again. Because the issue seems connected specifically to the ownership and permission state of newly modified files, I am trying to determine whether Virtualmin has a recommended configuration or workflow for ensuring that website files consistently receive the correct owner, group, and permission values.

The confusing part is that the website’s existing files generally continue working normally, while files that have recently been uploaded, extracted, copied, or replaced are the ones that can exhibit the problem. For example, I can have an existing directory containing several working PHP, CSS, JavaScript, and image files, then upload a new version of one file and discover that the updated version is no longer accessible through the website even though the previous version worked correctly. Looking at the filesystem shows that the new file exists in the correct directory, so there is no obvious missing-file problem. However, the ownership or permission information can differ from the surrounding files. Since Virtualmin manages individual virtual servers and their associated users and groups, I am wondering whether files created through different methods are sometimes being assigned to different accounts or groups. I have used normal website management methods and have also performed file operations from the server when necessary, but I would like to understand the correct Virtualmin approach so that files created by different methods remain consistent with the ownership expected by the web server and the virtual server.

I have already tried manually comparing the permissions and ownership of working and non-working files, and this seems to provide the strongest clue so far. When a problematic file is changed back to the same owner, group, and permissions as a nearby working file, the website can generally access it normally again. However, manually correcting every affected file is not a practical long-term solution, especially when the website receives regular updates and new files. I also do not want to simply make everything world-writable or apply excessively broad permissions because that could create a security problem and would not address the underlying reason for the incorrect ownership. What I would like to understand is whether Virtualmin has any mechanism that controls the default ownership and permission behavior for files created inside a virtual server, and whether Apache or PHP-FPM should be accessing those files under a particular user or group. If there are recommended commands for checking the expected ownership of a Virtualmin virtual server and comparing it with the actual ownership of newly created files, I would appreciate guidance on those as well.

Another thing I am trying to determine is whether the ownership changes are happening because files are being created by different processes running under different Linux users. The website itself may create or modify files while PHP is processing requests, while other files may be uploaded or updated through Virtualmin, SSH, SFTP, or another administrative method. If these processes operate under different users, I can understand how new files could potentially inherit different ownership from the files that were already present. What I am not sure about is which ownership model Virtualmin expects for a normal website and how PHP-FPM, Apache, and the virtual server’s Unix account should interact with that model. I would prefer to configure the server correctly rather than repeatedly changing file permissions after a problem appears. I am particularly interested in whether Virtualmin provides a standard way to repair ownership recursively for a single virtual server without affecting other websites hosted on the same machine, and whether there are any important precautions I should take before running such a repair on a production website.

For reference, I am providing my current system information below because I suspect the exact Virtualmin, Webmin, operating system, and web-server versions may be relevant when determining how file ownership and permissions are handled. The server is running Ubuntu 24.04 LTS with Webmin 2.303 and Virtualmin 7.8-2. Apache 2.4.58 is being used as the web server, with PHP 8.3 and PHP-FPM 8.3 handling PHP requests, and MariaDB 10.11 is installed for the website’s database requirements. I am keeping this question focused specifically on the ownership and permission state of newly created or updated website files rather than combining it with separate DNS, SSL, email, database, or performance problems. The main thing I want to solve is why files belonging to the same website can sometimes receive different ownership or permissions depending on how they were created or updated. If there are specific Virtualmin settings, commands, logs, or permission-repair tools that I should check, I would be happy to provide their output.

Has anyone experienced a similar situation on Virtualmin where files belonging to a virtual server are created with inconsistent ownership or permissions, particularly when the files are updated through different methods? I would like to know what the recommended ownership and permission structure should look like for a normal Virtualmin-managed website and how I can make sure newly created files automatically follow that structure. I would also appreciate advice on the safest way to identify which process is creating files with the unexpected ownership and whether Virtualmin has a built-in method for restoring the correct ownership and permissions for one virtual server. My goal is to fix the underlying configuration so that future uploads and website-generated files consistently remain accessible to the web server without requiring manual permission changes each time. If there are particular Virtualmin commands or diagnostic checks that would help identify where the ownership mismatch is coming from, I would appreciate any suggestions. Thanks!

Webmin 2.303 is over a year old and it might be prudent to upgrade it to the current version 2.670 to make sure that everything webmin wise is up to date. Also you don’t mention which version of virtualmin you are using and which method are you using to upload the files to the server

Please be concise. I have a hard time following long explanations (this is my failing, but I’m almost always the best person to help you on this forum, so if you cater to my particular limitations, you’ll get faster/better help).

I don’t think you’ve said who owned the problem files. If root, I have a simple explanation: File Manager when called via the Webmin menu (or a “Favorites” shortcut to same), performs operations as the logged in user. You need to go through the Virtualmin menu for the specific domain to have it behave as the domain owner. (And, I think that’s configurable, though it’s the default.) If something other than root and other than the owner of the domain, then it’s a bug.

And, as noted, you’ve got to run up to date software, no one should be wasting time trying to figure out problems in old software. It may be a bug that has long been fixed, and it’d be a huge waste of everyone’s time to track it down again.

From our forum guidelines: “Test first with a fully updated system.”

Thanks for pointing that out. I’ll check the Webmin version and consider upgrading it before continuing the troubleshooting, since it makes sense to rule out an outdated Webmin component. I’m also using Virtualmin for the virtual server, and the files are being uploaded or updated through different methods, which may be relevant because the ownership seems to vary depending on how a file is created.

Stick to one method of upload rather than various methods given that the problem may be diagnosed