suPHP file permission

Discussion in 'General' started by catalyst, Mar 31, 2007.

  1. catalyst

    catalyst New Member

    I follow the "How To Set Up suPHP On A Debian Based ISPConfig Server" to setup the suPHP.
    Yes, I can install the suPHP but when I upload a photo to my website. The php scripts will create a folder with access right 600 only and the upload photo also is 600 only. So that I can't see the photo on my browser.

    I have already set the suphp.conf to :
    ; Security options
    allow_file_group_writeable=true
    allow_file_others_writeable=false
    allow_directory_group_writeable=true
    allow_directory_others_writeable=false

    What's wrong with my suPHP, How can I fix this problem? In fact, I want to suPHP to chmod 755 or 644 to the created folder and files.
     
  2. till

    till Super Moderator

    This depends onyl on your PHP script and not on SuPHP, use the chmod function in PHP to change the mode to suit your needs.
     
  3. catalyst

    catalyst New Member

    Hi Till,

    I have looked all over the php scripts, this is not related to the php script, because the script is already used 755 to set the permission.
    Any other suggestion to fix this problem?
    Thank you!
     
  4. catalyst

    catalyst New Member

    Besides, I find the if the script chmod(filesorpath, 755), the output permission will be 0700.
    If the script use imagejpeg(), the permission of the output file will be 0600.
    Which configuration file should I modify it to fix this problem.
    The created folder or file owner is web1_user1:web1

    Thanks!
     
  5. till

    till Super Moderator

    In the php chmod command, you should always use chmod(filesorpath, 0755) and not chmod(filesorpath, 755), if the 0 is missing, the command might fail or set wrong permissions.

    I think there are only 2 possible files. The suphp.ini and the php.ini file where such a config value might be set.
     
  6. catalyst

    catalyst New Member

    Yes! I just ignore the '0' here. But inside the scripts, it use 0755.
    I have tried install a fresh Ubuntu again. I just put the a test script inside it,
    which is as the following (test.php)
    <?php
    chmod("test1.php", 0755);
    mkdir("test", 0755);
    ?>

    I find that the first command is working properly which can change the permission of test1.php to 0755.
    But the second one can only created a folder with 0700 only.

    I have checked the suphp.ini and php.ini and can't find any hits to change permission.

    Any idea where can I fix it?
    Thank you!
     
  7. till

    till Super Moderator

    Have you tried something like this too?

    mkdir("test");
    chmod("test", 0755);
     
  8. catalyst

    catalyst New Member


    NO! Because the scripts also use imagejpeg() to create images. The created images also with permission 0600. Then I can't read the images on the browser too. I don't want to modify anything in the scripts because there are quite many place in the scripts use the imagejpeg, mkdir, function.
    In the past, I use a server without any website control panel, there is not problem for the permission issues.
     
  9. till

    till Super Moderator

    But this has nothing to do with the fact of using a website controlpanel or not. ISPConfig creates just a apache config file for you, nothing more.

    Have you used suphp with your manual configuration too?
     
  10. catalyst

    catalyst New Member

    I didn't modify any configuration which is generated by suphp.
     
  11. catalyst

    catalyst New Member


    Yes!
    If mkdir("test") and chmod("test", 0755), the final permission will be 0755.

    Why can't use mkdir("test", 0755) directly?
    How and where can I change the default permission of mkdir() & imagejpeg()?
    Thank you!
     
  12. catalyst

    catalyst New Member

    I find out where to set the default permission when using mkdir() & imagejepg()

    just vi /etc/suphp.conf
    modify :
    umask=0077

    to
    umask=0022

    Then the mkdir() will create a folder with 0755
     
  13. catalyst

    catalyst New Member

    But there is another problem.
    If I set chmod 0777 to a php script, I will get the following error.

    500 error - Internal Server Error!

    I need to set it back to 0755 to avoid this error.

    Besides, can I modify the suphp.conf to avoid this error?
    If yes, where should I modify it?

    Thanks!
     
    Last edited: Apr 2, 2007
  14. catalyst

    catalyst New Member

    I find it now :
    Modify the Security Options :

    allow_file_group_writeable = true
    allow_file_group_others_writeable = ture
    allow_directory_group_writeable = true
    allow_directory_others_writeable = true

    where _file_ is the security option of a file and _directory_ is the security option of a directory.
     
    Last edited: Apr 2, 2007
  15. ethanlifka

    ethanlifka New Member

Share This Page