The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

apache username

Discussion in 'EasyApache' started by .NM., Oct 15, 2009.

  1. .NM.

    .NM. Registered

    Joined:
    Oct 15, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    This probably isn't even anything to do with cPanel, but my host isn't being particularly helpful and they told me to come here, so I'm here and asking you anyway.

    It's a bit of a long story so bare with me, basically:

    - I purchased a dedicated server about a week ago

    - I cannot get php functions such as fopen() chmod() chown() mod_uploaded_file(), etc... to work, as I get an error about permission being denied. (They work when the files are 0777 sometimes, but not always, and besides, I'd rather not have them as 0777).

    - I went to a programming forum to ask for help and I was told it had to do with users and groups. They told me firstly to get the permissions info about any file I was trying to write to, so I choose one (Note: That I also need the fopen() function to create new files when they don't exist, so changing them all to 0777 or something wouldn't really work) and got the following:

    Code:
    -rw-r--r-- 1 nobody nobody 339 Oct 11 15:00 11.10.2009.inc.txt
    root@*** [/home/***/pieces/staff/access-logs]#
    
    - I was told in response to that: "you'll need to find out your apache username". So I checked all the users on the machine, but no "apache".

    - So I went to my host and asked what the apache username was for my machine, but they said: "It is highly likely that the username is root and the password is blank (empty). Failing this find your config.inc.php file or similar and open that file with your text editor and search for the password / username within this file."

    - So I went ahead and tried the next stage of what I was told on the programming forum with the username "root":

    Code:
    usermod -a -G nobody root
    
    - Didn't help.

    - So then I tried looking for that config.inc.php file and got only: "find: config.inc.php: No such file or directory".

    - Once more I went back to the host to ask about this apache username, as the person on the programming forum said that since they installed it they should know it. They said: "I believe PHP does indeed come with cPanel installation. The installation process is automated and we do not specify any credentials during the process. cPanel uses the server's root password so we don't even have to set this up.

    You can get additional help and information on setting up cPanel/WHM at the following address:
    http://www.cpanel.net/support/docs/index.htm"

    - Since then I have checked the permissions of the files again and they have changed from nobody nobody to myusername myusername, where "myusername" is the username of my website. (Eg: /home/myusername/...)



    ....


    So, is there any way that I can find out this elusive apache username through cPanel/WHM? Or am I just to resign myself to never being able to use these functions on my server? :-(

    Thank you for reading.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,482
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Are you attempting to run this script whatever it is, from a user account located in home/usersname/public_html/ directory of some sort? If so the user would not be apache, (in fact it would never be user apache on a cPanel server,) it should be usersname running it.

    You don't want anything running as root unless you are absolutely sure you need to.

    You might ask your host if your server is running SuPHP. (Assuming no as you mention some files set to 777 perms and these file would not work at all in a SuPHP environment set to 777) If not, files might have had ownership changed via this/some PHP script, which would make them owned by username nobody and therefore not able to be edited by you or anyone else until ownership is changed back to usersname using chown command.

    Code:
    -rw-r--r-- 1 [B]nobody nobody [/B]339 Oct 11 15:00 11.10.2009.inc.txt
    Anything you search for as you've mentioned you found info at a programming forum, make sure the word cPanel is in your search somewhere. You might be able to get more relevant results that way.
     
  3. .NM.

    .NM. Registered

    Joined:
    Oct 15, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Yes I am attempting to run it from a user account.

    I have looked through all the files again and most of them have myusername myusername as user and group, and they aren't working, but I have managed to get it to work now by changing the directory of the files I want to write to, to nobody nobody. It's not a particuarly great fix, as now I have to go into SSH just to do things like delete files in those directories, but it works for now until I can work out how to fix it properly :-/
     
  4. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Infopro is on the right track in that it may be best if your PHP handler is switched to SuPHP (and to also ensure that SuExec is enabled). This will avoid having to change file and directory ownership from user:user. The main caveats are that you should ensure that directories have access (chmod) permissions of 0755 and files with 0644, and that your directories and files are owned by user:user instead of user:nobody.

    You may toggle or switch between preferences for SuExec and the PHP handlers (e.g., SuPHP) via your root WHM control panel at the following menu path:
    WHM: Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration

    I recommend the following documentation for additional details and cautionary information about the available PHP handlers:
    ApachePHPRequestHandling < EasyApache3 < TWiki

    To learn more about how to switch the PHP handler, following documentation should also help:
    ConfigurePhp < AllDocumentation/WHMDocs < TWiki
     
Loading...

Share This Page