Wordpress media upload: directory unwritable

SYSTEM INFORMATION
OS type and version Ubuntu Linux 24.04.1
Virtualmin version 7.30.4

I run Wordpress on several virtual machines on the same server. On one, when I try to upload media, I get

Unable to create directory uploads/2025/01. Is its parent directory writable by the server?

Permissions and owner:group were:

    public_html      0750  phil:phil
        wp_content   0755  phil:phil
            uploads  0755  phil:phil

Changing uploads 0755 to uploads 0777 gave the same error.
Other Wordpress sites on this server are a) set to 777; b) can upload media OK. This makes me think it is an ownership problem, not a permissions problem. Any ideas as to where I should look? One possible clue is that when I imported the WP installation with your wonderful tool, I changed the owner from philmaye to phil.
Thanks, Phil

First: Never chmod 777.

Are you sure your domain is actually running as user:group phil:phil?

Have you installed mod_php? (You should not have installed mod_php, but it can cause this problem.)

1 Like

Yeah, 777 is bad. I just wanted to rule out permission problems. A couple of screenshots. Seems: no mod_php; I am running as phil.


Have you tried:

Virtualmin → Limits and Validation → Validate Virtual Servers → Fix Permissions
(*) All servers
Fix Permissions Now

I’m guessing there’s a directory somewhere in the path leading up to that that phil can’t traverse.

If you log in as phil, can you actually browse to that directory and create files in it?

Wow, virtualmin has so many features! Thanks for the idea. Tried it, no difference.

I logged in as phil and created the directories 2025 and 2025/01, reinstalled Wordpress, and still get “Unable to create directory…” It is as if the WP uploader is looking in the wrong place. Tried: deactivating all plugins. A different browser. A different win10 machine. Rebooting the server. None fixed the problem.
Yes, the path looks clean to me:

phil@host:~/public_html/wp-content/uploads/2025/01$ pwd
/home/phil/public_html/wp-content/uploads/2025/01

Are you installing Wordpress from the VirtualminApps, or from a download directly from Wordpress’ website?

As far as I understand, it was installed as part of the import. Below are my notes with which I imported about 10 domains with Wordpress. It’s important to note that on most of the domains, Wordpress is working fine, and has been for ~6 months. It’s just this single domain, and on this domain, WP is working, e.g. create post, update plugins, delete spam,… It’s just uploading media that is broken??!

  • cPanel –> Backup –> Download a Full Account Backup.
  • download, move to E:\data\hetzner\cPanel-backups
  • use Webmin > Tools > Upload and Download to /root
    better for large files: move file to public_html, use “Download from web”
  • VirtualMin AddServers → Migrate Virtual Server → fill in username & password to match KH (my old hosting provider)
    → Create webmin user: Yes
    click to manage it → enable Apache SSL website, Spam filtering; disable DNS domain; MariaDB:maybe
  • Set up DNS records in Namecheap/wherever MUST DO BEFORE SSL SETUP
  • Manage Virtual Server > Setup SSL cert > LetsEncrypt > Request cert
  • Various dirs and files aren’t needed in /home/username/
    .cpanel .cphorde .softaculous, etc. I’ve been moving them to /root/from-username/
  • Mail forwarding: Usermin > Mail > Mail Forwarding and Replies

In filemanager does owner and group look fine? Also imported .htaccess file may cause a issue.

What is the WordPress media directory path configured as? If it’s an absolute path that ends up anywhere other than the user’s home, it will fail.

Also, have you enabled the chroot jail (Jailkit) feature for this domain? I usually recommend against doing that without doing some reading about the implications/risks/complexity of doing that.