• I have a localhost installation with MAMP up and running. This installation was created via a database backup from a production site. The settings in the database where adapted via phpMyAdmin. I am able to alter existing posts and to create new posts as well. When I try to upload new images I get an error message like “Unable to create directory wp-content/uploads/2015/08. Is its parent directory writable by the server?”

    Here’s what I tried to solve the problem:
    . checking forum entries (like this one)
    . logging in and out
    . restarting MAMP
    . trying to adapt the directory permissions w chmod 755
    . trying to adapt the directory permissions w chmod 777

    My MAMP installation runs as “kate”. That is my username.

    My setup:
    . WP 4.7
    . DIVI 3.0.24
    . MAMP 3.0.7.3
    . MacOS 10.10.5

    Thanks a lot for your feedback.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    The MAMP control panel may be running as “kate”, but the Apache server is running as whatever user is set in its configuration file. It’s typically “_www” but you should verify this. If you change system file ownership to this user, it will prevent the errors you are getting, but then “kate” will not be able to change these files.

    One solution is to add both “kate” and “_www” to a common group and set folder and file permissions to 775 and 664 respectively. This will solve most problems until something adds folders or files with the default 755 and 644, preventing group writes, so whoever is not the owner will be locked out of writes until the permissions can be fixed.

    • This reply was modified 7 years, 11 months ago by bcworkz. Reason: typo
    Thread Starter katering

    (@katering)

    Thank you very much for your quick reply,sounds all very reasonable. I will apply it asap but I do need some time to research the details as I’m a newbie to these admin-tasks.;)

    Thread Starter katering

    (@katering)

    Hmm … I performed all changes accordingly, rebooted the system and I still get the same error message.

    Status is now:
    . group _www created and user _www added to that group
    . adapted r/w permissions to all subdirectories of htdocs
    example of one directory: drwxrwx— 5 kate _www 170 28 Dez 21:38 uploads

    I still get the same error: “Unable to create directory wp-content/uploads/2015/08. Is its parent directory writable by the server?”

    Where am I wrong?

    Moderator bcworkz

    (@bcworkz)

    Are you sure the group r/w permission was applied to that specific parent directory? I’ve sometimes had trouble with applied permissions being propagated throughout the tree.

    Did you confirm _www is really the user used by your Apache install? The configuration file is usually httpd.conf, I’ve also seen apache2.conf. Now that you’ve established a group, this should be added to the configuration. There should be an entry like this:

    User _www
    Group _www
    # extra line or else the above underscore doesn't display

    You must restart Apache after making .conf changes.

    My installation is different than yours, so the following may not apply. There was a comment in my .conf file telling me the user and group should also be set in the envars file. Like this:

    export APACHE_RUN_USER=_www
    export APACHE_RUN_GROUP=_www

    This is for use by a control script, but I’m not sure it’s used in MAMP. YMMV

    These are the only things I know of that cause such errors: wrong user, wrong group, or wrong permissions.

    Unrelated to the problem, I wondered why uploaded images are are going to /2015/08 instead of /2016/12. I soon realized that images go into the date folder based on the date of the post they are attached to, not the current date or image date. Maybe obvious to some, but it threw me for a bit ?? Otherwise, images for one post could be all over the place.

    • This reply was modified 7 years, 11 months ago by bcworkz. Reason: extra code line
    Thread Starter katering

    (@katering)

    > Are you sure the group r/w permission was applied to that specific parent directory?
    Yupp, just double-checked again. All permissions are set for htdocs and it’s subsequent directories.

    > Did you confirm _www is really the user used by your Apache install?
    Mine is apache2.conf for MAMP. There is an httpd.conf in /private/etc/apache2 from the MacOS X installation that is not used.

    I verified the apache2.conf from MAMP and detected that it runs as

    User kate
    Group #-1

    Ups.. this is embarassing. Because user kate is me. I am the administrator and I do have all necessary -rwx permissions on all needed directories. So does _www. ??

    > These are the only things I know of that cause such errors: wrong user, wrong group, or wrong permissions.
    screenshot
    Definitely no clue how to improve that further.

    > Unrelated to the problem, I wondered why uploaded images are are going to /2015/08 instead of /2016/12.
    My assumption is that WP is throwing just a wrong error message here. Usually it should open a new directory /2016/12 or likewise, shouldn’t it? To be honest this message scares me a bit but I haven’t found any evidence for that problem while researching that via Google.

    • This reply was modified 7 years, 11 months ago by katering.
    Moderator bcworkz

    (@bcworkz)

    Apparently MAMP has upgraded its installation script to run Apache as the installing user instead of an arbitrary _www. A good move, too bad I was unaware of this, my apologies.

    I just thought of a couple other possibilities. Do you have any kind of security running? On localhost I’d think not. Check all .htaccess files along the path and insure there is no rule that could be restricting access.

    I assumed you were uploading an image while editing a post originally published August 2015. If so, creating the /2015/08 folder is normal behavior. If not, more is broken than error reporting.

    I agree with your latest assumption. If all permissions are in order, the error message itself is suspect. Are you using WP in its default state — no plugins and one of the twenty* themes? If not, try that and see if it makes any difference. A long shot, but we’re entering drastic measures territory.

    The next step after that is manually reinstalling WordPress. If you’re comfortable coding PHP, you could trace through the image upload process and try to locate where things go wrong. More than likely you’ll end up at mkdir() returning false, which is expected and doesn’t really help us any. But if it is something else, this would find it. It’s a very tedious, time consuming process that even an expert coder would be reluctant to undertake.

    If reinstalling WP fails to help and you understandably skip the trace process, then MAMP itself is suspect. I did have trouble once with PHP in an very similar LAMP installation, so it’s not unheard of. You’re not using a beta version of MAMP are you? I don’t think there’s much we could do to debug MAMP other than reinstalling. You could try reverting to one version earlier in case there’s some newly introduced bug that only manifests itself in rare cases.

    You could possibly consider one of the alternatives to MAMP if the problem persists despite all of our efforts. Depending on the root cause of this, it may or may not help.

    I’m truly out of ideas now. My biggest fear is I missed something simple and had you go through all of this reinstalling for no reason. Since privileged access to people’s installations is beyond the scope of these forums, it’s easy to miss something that sitting at your computer might solve. Consider getting an expert local to you that is trustworthy to figure this out for you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Image permissions w localhost and MAMP’ is closed to new replies.