Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to make Wordpress work. I currently have this error message:

Could not create directory. /var/www/html/wp-content/upgrade/theme_name

when trying to upload a theme. This is the permissions set to /var/www/html/wp-content/upgrade/

drwxrwxr-x 3 ec2-user apache 4096 Jun 21 00:30 upgrade

chmod 777 upgrade makes the error go away. But that is not considered best practice. However, I think this should work too... why not?

I guess the web server may not be included by the above permissions. What group should I use to allow the web server to write?

(My setup is Amazon EC2, Amazon Linux AMI with httpd)

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

I don't know anything about Amazon EC2, but you should be able to:

  1. Retrieve the name of the user running Apache with a command similar to this:

    ps aux | grep apache # The username should be in the first column.
    
  2. Retrieve the groups this user is part of with the groups(1) command:

    groups [USERNAME]
    
share|improve this answer
    
The first column is apache, and groups apache return apache : apache. A line from the first commmand looks like this: apache 11171 0.0 3.4 39984 21516 ? S Jun20 0:02 /usr/sbin/httpd –  Calle Jun 21 '12 at 11:14
    
User apache clearly has permissions to write in the directory. You say chmod 777 solves the issue, so I am guessing you're using a different user to upload your themes. I don't know Wordpress very well. According to this answer try changing ownership to user www-data. –  rahmu Jun 21 '12 at 11:28
    
Thank you for taking the time to look up the article and everything. It was indeed a different user, as I realized Wordpress used FTP to do its work. I found out that user by what was suggested below and then added group apache, found out by step 1, to it. That solved it. –  Calle Jun 21 '12 at 16:55
add comment

chmod 777 upgrade makes the error go away.

Well, in that case ls -ld /var/www/html/wp-content/upgrade/theme_name should reveal creator's credentials, which you can use for precise access granting.

And it's better using 1777 (as for /tmp) since at least it guarantees that only owner of a file would be able to unlink it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.