Apache creating files/folders with user "nobody", but needs to be another user

Discussion in 'Apache' started by tyler_durden, Mar 19, 2011.

  1. #1
    I currently have a CMS creating cache files/folders that should be deleted after a certain time but are not. After WEEKS of researching (no exageration), I have figured out the problem. These cache files/folders are being created with Apache, giving it the user "nobody". This was working just fine on a previous host with SuPHP, but I moved to mod_php with a new VPS.

    Here are a few of my issues, looking for the best solution(s).

    1) I wanted eAccelerator on my system, so in Jan my host converted my php to mod_php. This is when the problem started. My host told me (which I have confirmed) that eAccelerator cannot run in SuPHp mode, and must be mod_php or FastCGI. My host recommended mod_php stating FastCGi was "relatively unstable and hence not recommended".

    So basically I want php to run with an accelerator (eAccelerator is not required but preferred), AND files created by Apache need to have a user other than "nobody". What options do I have? Thanks for any help!
     
    tyler_durden, Mar 19, 2011 IP
  2. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #2
    Hello there,

    How are you trying to remove these files that the user/group nobody is giving you errors?

    Chris
     
    RHS-Chris, Mar 19, 2011 IP
  3. rod.maqstuirt

    rod.maqstuirt Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    apache creates files with username:group defined in httpd.conf, I don't get what the problem is? Files are not deleted? How are You deleting them? Cronjob? Perl or PHP script?
     
    rod.maqstuirt, Mar 20, 2011 IP
  4. tyler_durden

    tyler_durden Peon

    Messages:
    340
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    They are supposed to be deleted through a php script run through cron in my CMS. I tried creating my own delete file/folder script to delete them and it errors out with permission denied errors. It runs just fine through the browser. I guess I'm not 100% sure that is the issue with the CMS/cron script, but my delete file script will work just fine if the owners are correct.

    rod.magstuirt, can you elaborate more on where this is in the httpd.conf file? The only thing I see for "nobody" is:

    <code>PidFile logs/httpd.pid
    LockFile logs/accept.lock
    # Defined in /var/cpanel/cpanel.config: apache_port
    Listen 0.0.0.0:80
    User nobody
    Group nobody</code>
     
    tyler_durden, Mar 20, 2011 IP
  5. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #5
    You really should not be messing around with the user that Apache runs as, you will run into other issues, such as directory and file permissions for the server when running. Are you using a main stream CMS, or something custom?

    Chris
     
    RHS-Chris, Mar 20, 2011 IP
  6. tyler_durden

    tyler_durden Peon

    Messages:
    340
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm using Drupal, one of the more popular CMS.

    Even though Apache is running as mod_php with no user/owner, is there a setting I can change so new files and folders created by Apache have a certain user? Or would that cause other problems with tmp files, etc?
     
    tyler_durden, Mar 20, 2011 IP
  7. rod.maqstuirt

    rod.maqstuirt Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    well first of all php is running as mod_php for apache. I think there is something wrong with Drupals cron. Try to put something like:
    <?php
    function AddToLog($str){ 
        $fh = @fopen("log.txt", 'a'); 
        @fwrite($fh, $str."\n");
        @fclose($fh);
    }
    
    $who = exec('whoami');
    AddToLog($who);
    ?>
    Code (markup):
    And check for output in log.txt file. Maybe Drupal's cron runs as different user...
     
    rod.maqstuirt, Mar 21, 2011 IP