Apache/PHP Configuration Issues

Discussion in 'PHP' started by denniswimer, Nov 14, 2007.

  1. #1
    I have been experiencing issues in accessing subdirectories of 'doc_root' (htdoc), which, in my case, is '/var/www/html' (Fedora). I have Apache 2.2.6 and PHP 5.1.6 installed. I can successfully run php scripts that reside in 'doc_root' (i.e. phpinfo()), but cannot access files in any subdirectory location.

    Here is a php script that might explain better.
    
    <?php
    // The following checks to see if the file 'class.user.php'
    // exists in the cgi-bin directory. The full path to this
    // file is [ /var/www/html/cgi-bin/class.user.php ] and is
    // a real file that actually does exist as specified above.
    
    $filename = "cgi-bin/class.user.php";
    
    if (file_exists($filename)) {
        echo "The file $filename exists.";
    } else {
        echo "The file $filename does not exist.";
    }
    ?>
    
    <br/>
    
    <?php
    // The following checks to see if the file 'confirm.php'
    // exists in the current directory. The full path to this
    // file is [ /var/www/html/confirm.php ] and is
    // a real file that actually does exist as specified above.
    
    $filename = "confirm.php";
    
    if (file_exists($filename)) {
        echo "The file $filename exists.";
    } else {
        echo "The file $filename does not exist.";
    }
    ?>
    
    Code (markup):
    Both files exist in their respective locations. Parent directories for both are set to 777 permissions. Both files are set to 777 permissions. Here is the result of execution of this php script.
    
    The file cgi-bin/class.user.php does not exist.
    The file confirm.php exists.
    
    Code (markup):
    I having been pulling my hair out trying to figure out what sort of setting (Apache or PHP) that might be causing this. Any assistance would be greatly appreciated.
     
    denniswimer, Nov 14, 2007 IP
  2. mvl

    mvl Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does file_exists($filename) tell you in the next two cases?

    $filename = '/var/www/html/cgi-bin/class.user.php';

    and

    $filename = './cgi-bin/class.user.php';
     
    mvl, Nov 14, 2007 IP
  3. denniswimer

    denniswimer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Makes no difference whether or not the full path is given. As shown in the previous example, 'confirm.php' in the htdoc directory is found. Here is the output with the full path coded.
    
    The file /var/www/html/cgi-bin/class.user.php does not exist.
    The file /var/www/html/confirm.php exists.
    
    Code (markup):
     
    denniswimer, Nov 14, 2007 IP
  4. denniswimer

    denniswimer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry -- neglected to use both suggestions. Here is the full output with both suggestions coded.
    
    The file /var/www/html/cgi-bin/class.user.php does not exist.
    The file ./cgi-bin/class.user.php does not exist.
    The file /var/www/html/confirm.php exists.
    
    Code (markup):
     
    denniswimer, Nov 14, 2007 IP
  5. denniswimer

    denniswimer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well, I have new information that might trigger a response. I began thinking about UID/GID issues and decided to create a new directory with the same owner/group/permissions as all the other subdirectories and copy a file into this new directory for test purposes. To my amazement, this new directory/file were totally visible.

    Is it possible this issue something to do with effective UID/GID? All the htdoc files were copied into this server, chown/chgrp/chmod. Obviously, this all happened after Apache/PHP were installed and running correctly with a series of test files.

    I feel like this is some sort of breakthrough, but, I still have no definitive answer to why this is happening or a resolution. I hope this new information will trigger memories of similar experiences and resolutions.
     
    denniswimer, Nov 15, 2007 IP
  6. denniswimer

    denniswimer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks to all who assisted in resolving this issue. It did turn out to be directly related to UID/GID and the effective UID/GID. The short answer is: I needed to create new directories and copy all the directories/files into each new directory. Once this was done, all was well with the world.
     
    denniswimer, Nov 15, 2007 IP