Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to enable WordPress to upload files to the wp-content folder without setting permissions for the folder to 777. However, I'm having some difficulties.

The group and user set for the wp-content folder match the group and user Apache is configured to be using in httpd.conf. However, when I run the below command, it appears that Apache is actually running as root rather than the user specified in httpd.conf.

httpd.conf Configuration

User xxx
Group yyy

Command Run to Determine User Apache is Running As

ps aux | grep httpd

Output from the above command

513       1294  0.4  1.4 316420 54864 ?        S    08:30   0:06 /usr/sbin/httpd

513 is the correct UID for user xxx, so that appears correctly. However, I'm still not able to upload files within WordPress without setting permissions for the wp-content folder to 777.

Can somebody tell me what the issue is here?

share|improve this question
    
You're running the check as root and it's showing the command "grep apache" as the process root is running! Try ps -ef | grep apache instead. –  Colin 't Hart Oct 17 '12 at 12:18
    
Bah...too early in the morning for stupid mistakes like that. So the user it is running as it "apache" listed at the end? –  Windows Ninja Oct 17 '12 at 12:20
    
First column is user. –  Colin 't Hart Oct 17 '12 at 12:21
    
So what am I missing here? If httpd.conf specifies apache should run as xxx, why don't I see that when I run this? –  Windows Ninja Oct 17 '12 at 12:37
    
What you're missing is that apache is not running at all. As mentioned by Colin, the process you're seeing is the grep command you're just executing. –  janneb Oct 17 '12 at 12:49

1 Answer 1

up vote 2 down vote accepted

Apache always needs to start as root, then it uses setuid to switch to user context of specified user in httpd.conf.

Without root (uid = 0) you can not create listening socket on privileged ports (below 1024)

For details read this documents:

From first link:

# ps -ef | grep -i http | awk '{print $1}'
root
apache
apache
apache
apache
apache
share|improve this answer
    
So am I supposed to let it run as root and then change it on a per site basis to a different user rather than universally? It doesn't really seem secure to let httpd run as root. –  Windows Ninja Oct 17 '12 at 13:07
    
@CrabbyAdmin : see my updated answer –  user106666 Oct 17 '12 at 13:11
    
Having read through the link, I've already got this setup correctly. However, I still can't upload to wp-content from WP even with the permissions set to 755. If WP (and httpd) are running as UID 513, as it says it is, shouldn't it be able to upload files without issue? –  Windows Ninja Oct 17 '12 at 13:21
    
@CrabbyAdmin which users is the owner for the wp-content/ directory? It should be the apache user (513 in your case). <code>chown -R 513 wp-content/ </code> should do it for you. –  Ken S. Oct 17 '12 at 13:32
    
@CrabbyAdmin please post ls -ld wp-content –  user106666 Oct 17 '12 at 13:35

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.