What to do if “WordPress can’t create an .htdocs file on my Mac”

One of the first things I wanted to do when I first got my MacBook was to install WordPress locally to use it as a development sandbox.

Even after following the tutorial at WP Candy I couldn’t get WordPress to work perfectly on the Mac. I uninstalled MAMP and tried using XAMPP, which I had used successfully on my PC. I had the same problem with both. First, you are not alone. (I was prompted to write this post when an EXPERIENCED developer friend had problems configuring WordPress properly on his brand new MacBook Air.)

After several futile Google searches and digging through the forums (http://wordpress.org/support/) I came up with this solution.

Symptoms

  • WordPress asks for an FTP password when trying to update a plugin. It wouldn’t take my login password, so I reverted to doing a manual update. It worked, but it’s not what we want.
    WordPress asks for FTP credentials
  • If you try to update your permalinks, WordPress chokes while trying tocreate an .htdocs file. It complains about not having permissions to write to the file:
    WordPress can't write to .htdocs file

Solution

Here is how I fixed the problem. I used the terminal to do this (I worked as a Unix Sysadmin for several years). (If there is enough feedback I might do a follow-up on doing it using the GUI an a mouse.)

1. Find the directory where the problem lives:

$ cd /Applications/XAMPP/xamppfiles

 

2. Check the permissions and ownership on the  htdocs folder:

$ ls -l

htdocs directory permissions

3. Find the username that your Mac knows you as. In my case it’s icet. I’ll use myuser for this example. Change the user and group of the folder. One command will do it; you will probably need to use sudo.

$ whoami
$ sudo chown -R myuser:staff htdocs

Change ownership of the htdocs directory

We’re getting closer but Apache still can’t write to the htdocs folder. We need to tell XAMPP to run Apache as someone else

5. Change to the directory where the configuration file lives:

$ cd /Applications/XAMPP/xamppfiles/etc/

6. Make a backup of the configuration file, then change permissions of the configuration file so you can edit it:

$ sudo cp httpd.conf httpd.conf.bak

$ sudo chmod 777 httpd.conf

7. Edit the User and Group lines in the httpd.conf file. I use vim because I’m already at the command line. The Mac’s built-in TextEdit application will work too.

$ sudo vi httpd.conf

7.1. Find the User and Group lines

#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

7.2 and change them so it looks like this (replace icet with your username from step 3):

#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
# User daemon
# Group daemon
User myuser
Group staff

httpd.conf after the fix

8. Stop and restart XAMPP

That should do it. You have given Apache the ability to write into the WordPress directory. It has worked fine for me for months.

Don’t do this on a production server! It probably introduces several security holes. Find a qualified server expert.

Share

About TJ
The Geek Who Speaks People, TJ has a both passion and a penchant for clarifying complex subjects.

Comments

2 Responses to “What to do if “WordPress can’t create an .htdocs file on my Mac””
  1. Maureen says:

    I see a lot of interesting posts here, i know writing articles
    requires a lot of time, but i know unlimited source of content for your page , just search in google – rewriter
    creates an unique article in a minute

  2. Suchl.ink says:

    Foг thee reason that mߋst are verry company focused,
    thе certification іs likely not recognized by anyone othesr than tһе firm that issued іt.

    Various Types of Baby Products Avаilable:
    Parents aim at buying the Ьᥱst baby products   ɑvailable іn market.

    Are yоu a smaⅼl business struggling tо find neᴡ clientele.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!