I have a few sites running on Virtualmin that allow files to be uploaded from within the CMS such as setting a profile pic or adding images to a web directory listing. For some reason on a couple of sites the images don’t display until I manually change their permissions to 0644 for files and 0750 for directories… Other sites work fine.
I just wondered if there is somewhere in Virtualmin you can set the default file permissions for uploads via CMS sites or PHP uploads?
And if there is some reason why some sites work and some don’t with this?
Thanks again for any help at all.
What PHP Execution Mode is it set to? Both FCGID and CGI should run as the Virtual Server owner, meaning the default permissions should work well.
But if it’s set to mod_php, that could cause the problem you’re describing.
You can see that in Server Configuration -> Website Options.
Hi thanks Eric. I’ve gone to the Virtual Server giving me the wrong upload permissions and clicked ‘Server Configuration > Website Options’.
Under where it says ‘PHP script execution mode’ nothing is selected (no bullet points blacked out) and there is only one option available there which is 'CGI wrapper (run as virtual server owner).
How do I enable the options for FCGID or mod_php etc. I’m pretty sure I did install mod_php because one of my sites required it… So if that’s the case and I’m stuck with it, can I select something else on another Virtual Server or at least configure it correctly to set the right permission?
Thanks again for the help.
Hi just an update that I’m still experiencing this issue. I also have an ownCloud installation and when I run its web updater all the permissions change to the wrong ones and the site doesn’t load. I then have to go the File Manager in Webmin and manually set all folders to 750 or 755 and files to 644.
Thanks if any one can please help with this.
While I don’t know how to prevent ownCloud from modifying it’s file permissions, it’s possible to update the permissions of your various web files by going into Limits and Validation -> Validate Virtual Servers -> Fix Permissions. There, you can fix the permissions for one or more domains.
Hi thanks Eric, I’ve ran that through on all my virtual servers to see if it helps.
The problem though isn’t just with ownCloud but other CMS software I’ve installed too for other sites/domains. For example I’ve also used some online free ads CMS software and when a user tries to post an add and puts photos on the images then don’t display so I have to manually chown them in the webmin File Manager to get them to work…
Hi sorry to re-bump this. But I can confirm ftp also doesn’t set the right permissions when a user uploads to their home directory. For example I use the CMS modx a lot. If I create a new virtual server and ftp in as the server admin user, then upload the cms files, when I then navigate to the web address to do the setup I get a permission problem/server not found error. I then have to go in and manually chmod all the files to 0644 and all the directories to 0755. But by default they are set when ftp-ed up at 0775 and 0664…
So I set all the permissions correctly to 0644 and 0755 and then Modx works great. But then when I login and use the CMS file uploader or gallery plugin or installer to add an addon, again I have to go out and set the permissions manually again.
So it’s not just Owncloud or FTP, but other CMS software too… Is there a way to set the default file permissions for non-root users so that when a CMS uploads a file as the domain owner/user or I ftp in it sets the directory to default 0755 and files to 0644?
Another example is also when selling hosting or a Virtual Server on to a client. If I install Wordpress for them it would be good to let them just then use it and use the plugins and installer within it, without me having to go back in when they install something from wordpress and set the permissions…
I hope that makes sense. Thanks again for any help. I don’t want to impact any security, but it’s just a pain to have to manually set permissions that the CMS or copied files should already set correctly.
I don’t know if this is to do with unmask, apache settings or ftp server settings or all of them, but my setup must be set a little wrong compared to others…
Hi Just to update, I found the fix for this.
I updated /etc/suphp/suphp.conf
and changed umask=0077 to be umask=0022
Now when uploading in a CMS or installing a module the correct permissions are used.