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.

PHP permissions

Discussion in 'General Discussion' started by james2, Sep 6, 2005.

  1. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I am using an account that I created using whm. PHP doesn't have permissions to write files. How can I fix that without using PHP in CGI mode or CHMODing the files to 777? I tried using CGI mode and that worked, but eAccelerator doesn't support PHP using CGI mode. By the way, how can I make my site support Apache2? PHP also can't upload files.
     
  2. astopy

    astopy Well-Known Member

    Joined:
    Apr 3, 2003
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    If PHP scripts are running as the apache user then that user needs write access to the file in order to write to it - you can either make it world-writable (which you already said you don't want to do), chgrp the files and chmod them to allow the group write access or chown them so they are owned by apache.
     
  3. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I have tried chown but it doesn't work. PHP is running as nobody so it doesn't work.
     
  4. kite

    kite Registered

    Joined:
    Jun 19, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Atlanta, GA
    Copy/Paste this to a new file:

    <?php

    echo phpinfo();

    ?>

    cPanel houses PHP for vhosts (on my machine) in /home/virthttpds/usr or something along those lines. If you are trying to upgrade to Apache2 or PHP5 you will have to update *this* php.ini to look for your apxs (I assume, /usr/local/apache2/bin/apxs).

    I am not sure if this helps or not. Good Luck regardless! =]


     
  5. amal

    amal Well-Known Member

    Joined:
    Nov 22, 2003
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Only other options are

    1. chgrp the directory to nobody ( I'm assuming that your apache is running as the user - nobody ), and then give it right permissions. ( You have to be root to do this )

    ie,

    chgrp nobody $dir ( and or $file )
    chmod g+w $dir ( and or $file )

    where $file is the absolute path of the file and
    $dir is the absolute path of the directory on which the file resides

    2. Enable phpsuexec or download and install suphp.. phpsuexec is the recommended option.. :)

    The user nobody needs write access to the directory where it's going to upload... Only then will it upload.

    ######
    Regards,
    Amal
     
  6. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    phpsuexec and suphp are cgi modes. i don't want php running in cgi mode.
     
  7. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    chgrp also doesn't work
     
  8. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    THIS IS AN EMERGENCY. I NEED TO FIX THE PERMISSIONS. :mad: :mad: :mad: :mad: :mad:
     
  9. amal

    amal Well-Known Member

    Joined:
    Nov 22, 2003
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    check the apache error log, when you try to open the page...
    and paste the logs here...

    also paste the result of

    ls -l directory
    ls -l directory/file
     
  10. james2

    james2 Member

    Joined:
    Sep 6, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    i used to do it that way but uploading new php files won't work. uploading files can't be deleted if you are not the root user. i must chmod the files again when i re-upload them. i must chmod the files when i upload them. uploaded files using php can't be deleted except the root user. i cannot update my site easily because of it. i spend too much time manually updating my site because php can't upload files. i am wasting time. i am always frustrated and angry becuase i can't upload the files. i am very mad. i hate rechmoding the files every time i upload them. i want apache to run php as the root user. i want my account have privileges as the root user since i created it. i am very mad for many days because i can't upload the files. i hate manually wasting time manually uploading files. php can't write files. i have to manually upload the files every time wasting too much time. my site hasn't been updated for a very long time because of it. my site is not updating as much as i want my site to update. i wasted hundreds of hours manually uploading files. i am very mad. i am always mad because of it. i don't know how to upload the files. i can't do anything else except spending hours every day fixing this problem. you don't know how much time i waste. i don't know how to fix it. i want to fix it immediately. could you show me how to fix this. :mad:
     
  11. phpman

    phpman Well-Known Member

    Joined:
    Sep 3, 2003
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Rio de Janeiro - Brazil
    James

    Send me your phpinfo.
     
  12. amal

    amal Well-Known Member

    Joined:
    Nov 22, 2003
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Why do u want to show ur anger with php on the cpanel forum.. You do not want to run php with phpsuexec, but you want to make php give u output similar to that. Then there is no point in having phpsuexec. phpsuexec's use is to solve this problem..

    And did you say you need php to run as root? Well, that'll be like sending a formal invitation for hackers to hack your server. They will get root access, if there is an exploit in a php program.

    And do remember that files uploaded using php will always have the ownership of nobody. The user CANNOT delete files under the ownership of nobody. Only options u have are

    1. Delete it with another php script.
    2. Write a cron on the server to change the permissions of the uploaded files , say every hour.
     
  13. astopy

    astopy Well-Known Member

    Joined:
    Apr 3, 2003
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    You should realise that no one here is under any formal obligation to help you. You might try being a little more polite...
     
  14. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Indeed. If you're in need of urgent support then you'll have to hire a server admin or seek help from your datacenter. These forums are not here to provide you with support, they're simply for server admins to exchange help and ideas about cPanel.

    Not relevant in this thread or any of the posters herein, but the keyword in that sentence that is overlooked by a notable few is exchange.
     
  15. jester.ro

    jester.ro Well-Known Member
    PartnerNOC

    Joined:
    Feb 6, 2004
    Messages:
    304
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bucharest, Romania
    cPanel Access Level:
    DataCenter Provider


    This sounds like a speech from MojoJojo :) .

    Anyway, you could modify your php scripts to do a chmod on the files AFTER uploading them.

    http://www.php.net/manual/en/function.chmod.php
     
  16. amal

    amal Well-Known Member

    Joined:
    Nov 22, 2003
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    :D

    Yeah, that's a nice point. I missed it.. :)
     
Loading...

Share This Page