Weird Permissions Problem With Includes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kwest

    Weird Permissions Problem With Includes

    I just setup a new server with PHP 5 and ran into a problem with
    includes. Everytime I call something like

    require_once './includes/test.inc'

    I get a permissions message like this:

    Warning: require_once(./includes/test.inc) [function.requir e-once]:
    failed to open stream: Permission denied in /var/www/html/test2.php on
    line 3

    Fatal error: require_once() [function.requir e]: Failed opening
    required './includes/test.inc' (include_path=' .:/php/includes:/var/www/
    html/includes') in /var/www/html/test2.php on line 3

    I verified that apache has exectuble permissions all the way through /
    var/www/html. As you can see my include path is correct (unless
    someone sees something I don't). This is getting really frustrating as
    I have spent several hour trying to debug this, any assistance would
    be greatly appreciated.

    I was able to run the script fine from the command line as well.

  • Carl

    #2
    Re: Weird Permissions Problem With Includes

    On Jan 30, 2:54 pm, "kwest" <kwes...@gmail. comwrote:
    I just setup a new server with PHP 5 and ran into a problem with
    includes. Everytime I call something like
    >
    require_once './includes/test.inc'
    >
    I get a permissions message like this:
    >
    Warning: require_once(./includes/test.inc) [function.requir e-once]:
    failed to open stream: Permission denied in /var/www/html/test2.php on
    line 3
    >
    Fatal error: require_once() [function.requir e]: Failed opening
    required './includes/test.inc' (include_path=' .:/php/includes:/var/www/
    html/includes') in /var/www/html/test2.php on line 3
    >
    I verified that apache has exectuble permissions all the way through /
    var/www/html. As you can see my include path is correct (unless
    someone sees something I don't). This is getting really frustrating as
    I have spent several hour trying to debug this, any assistance would
    be greatly appreciated.
    >
    I was able to run the script fine from the command line as well.
    Does each included script have read permission as well?

    Carl.

    Comment

    • Carl

      #3
      Re: Weird Permissions Problem With Includes

      On Jan 30, 3:36 pm, "Carl" <c.gro...@gmail .comwrote:
      On Jan 30, 2:54 pm, "kwest" <kwes...@gmail. comwrote:
      >
      >
      >
      I just setup a new server with PHP 5 and ran into a problem with
      includes. Everytime I call something like
      >
      require_once './includes/test.inc'
      >
      I get a permissions message like this:
      >
      Warning: require_once(./includes/test.inc) [function.requir e-once]:
      failed to open stream: Permission denied in /var/www/html/test2.php on
      line 3
      >
      Fatal error: require_once() [function.requir e]: Failed opening
      required './includes/test.inc' (include_path=' .:/php/includes:/var/www/
      html/includes') in /var/www/html/test2.php on line 3
      >
      I verified that apache has exectuble permissions all the way through /
      var/www/html. As you can see my include path is correct (unless
      someone sees something I don't). This is getting really frustrating as
      I have spent several hour trying to debug this, any assistance would
      be greatly appreciated.
      >
      I was able to run the script fine from the command line as well.
      >
      Does each included script have read permission as well?
      >
      Carl.
      Sorry, that didn't come out right at all.

      What I meant to ask was if the apache user had read access each script
      you are trying to include? I don't believe that execute permission is
      required.

      Carl.

      Comment

      • kwest

        #4
        Re: Weird Permissions Problem With Includes


        Carl,

        Yes that is the weird thing, I gave read and execute permission to the
        incude I even chmoded them all to 777 to debug the problem and still
        get the same error.

        If I run the script from the command line it works. So am guessing it
        has to be something with Apache. I am using Apache 2 if that helps.

        Thank You

        - Ken
        Carl.
        >
        Sorry, that didn't come out right at all.
        >
        What I meant to ask was if the apache user had read access each script
        you are trying to include? I don't believe that execute permission is
        required.
        >
        Carl.

        Comment

        • Jerry Stuckle

          #5
          Re: Weird Permissions Problem With Includes

          kwest wrote:
          Carl,
          >
          Yes that is the weird thing, I gave read and execute permission to the
          incude I even chmoded them all to 777 to debug the problem and still
          get the same error.
          >
          If I run the script from the command line it works. So am guessing it
          has to be something with Apache. I am using Apache 2 if that helps.
          >
          Thank You
          >
          - Ken
          >
          >>Carl.
          >Sorry, that didn't come out right at all.
          >>
          >What I meant to ask was if the apache user had read access each script
          >you are trying to include? I don't believe that execute permission is
          >required.
          >>
          >Carl.
          >
          >
          Carl,

          PHP scripts are not executed. They are interpreted. You should not
          have execute privileges on them.

          Your error message indicates the Apache user does not have read access
          to the scripts. But this can also show up if you give the file too many
          privileges - like 777.

          Try just giving it read access to everyone. Or make the Apache user a
          member of the group which owns the file and give the file group read access.

          Of course, you could also make the apache user the owner of the file.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Carl

            #6
            Re: Weird Permissions Problem With Includes

            On Feb 2, 7:13 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            kwest wrote:
            Carl,
            >
            Yes that is the weird thing, I gave read and execute permission to the
            incude I even chmoded them all to 777 to debug the problem and still
            get the same error.>
            If I run the script from the command line it works. So am guessing it
            has to be something with Apache. I am using Apache 2 if that helps.
            >
            Thank You
            >
            - Ken
            >
            >Carl.
            Sorry, that didn't come out right at all.
            >
            What I meant to ask was if the apache user had read access each script
            you are trying to include? I don't believe that execute permission is
            required.
            >
            Carl.
            >
            Carl,
            >
            PHP scripts are not executed. They are interpreted. You should not
            have execute privileges on them.
            >
            Hi Jerry,

            I think you misread the attribution on earlier posts in this thread
            and mistakenly addressed your post to me instead of the orig poster,
            Ken. I certainly never recommended that the scripts need execute
            access, and actually suggested that they do not.

            As a side note, PHP scripts can infact be executed by the shell
            directly (using the "shebang" to invoke the PHP interpreter) when
            calling PHP scripts from the command line, cron jobs, etc. In these
            cases, execute privileges should be given to the user/group. This does
            not apply to this case, however.
            Your error message indicates the Apache user does not have read access
            to the scripts. But this can also show up if you give the file too many
            privileges - like 777.
            >
            What?!? Why would setting a file permission to 777 deny read access?
            It should do exactly the opposite, giving owner, group and all users
            complete access to the file! Do you have any sort of reference or
            citation for this claim?

            @ Ken,

            This thread was two days inactive when Jerry revived it, and I hope
            you solved your problem by now. If not, double check the permissions
            on the file and any directories leading to the file and post back if
            your still having problems.

            Cheers,
            Carl.
            Try just giving it read access to everyone. Or make the Apache user a
            member of the group which owns the file and give the file group read access.
            >
            Of course, you could also make the apache user the owner of the file.
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstuck...@attgl obal.net
            =============== ===

            Comment

            • Jerry Stuckle

              #7
              Re: Weird Permissions Problem With Includes

              Carl wrote:
              On Feb 2, 7:13 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
              >kwest wrote:
              >>Carl,
              >>Yes that is the weird thing, I gave read and execute permission to the
              >>incude I even chmoded them all to 777 to debug the problem and still
              >>get the same error.>
              >>If I run the script from the command line it works. So am guessing it
              >>has to be something with Apache. I am using Apache 2 if that helps.
              >>Thank You
              >>- Ken
              >>>>Carl.
              >>>Sorry, that didn't come out right at all.
              >>>What I meant to ask was if the apache user had read access each script
              >>>you are trying to include? I don't believe that execute permission is
              >>>required.
              >>>Carl.
              >Carl,
              >>
              >PHP scripts are not executed. They are interpreted. You should not
              >have execute privileges on them.
              >>
              >
              Hi Jerry,
              >
              I think you misread the attribution on earlier posts in this thread
              and mistakenly addressed your post to me instead of the orig poster,
              Ken. I certainly never recommended that the scripts need execute
              access, and actually suggested that they do not.
              >
              Yep, sorry. By the time I got here I had already read over 1500
              messages in several newsgroups. To say my brain was a little fried
              would be an understatement :-). Sorry.
              As a side note, PHP scripts can infact be executed by the shell
              directly (using the "shebang" to invoke the PHP interpreter) when
              calling PHP scripts from the command line, cron jobs, etc. In these
              cases, execute privileges should be given to the user/group. This does
              not apply to this case, however.
              >
              Yep, it doesn't apply, which is why I didn't mention it here. No use
              tossing in unnecessary complications.
              >Your error message indicates the Apache user does not have read access
              >to the scripts. But this can also show up if you give the file too many
              >privileges - like 777.
              >>
              >
              What?!? Why would setting a file permission to 777 deny read access?
              It should do exactly the opposite, giving owner, group and all users
              complete access to the file! Do you have any sort of reference or
              citation for this claim?
              >
              @ Ken,
              >
              Because PHP doesn't like a file with *too much* permission. Can't say
              as I agree with the PHP developers - but it seems the check it at times
              and don't allow you to open a file with too much access.

              For reference - search this newsgroup for other, similar messages. It
              pops up every couple of weeks. And while I've seen the problem, I've
              never seen this documented anywhere.

              This thread was two days inactive when Jerry revived it, and I hope
              you solved your problem by now. If not, double check the permissions
              on the file and any directories leading to the file and post back if
              your still having problems.
              >
              Cheers,
              Carl.
              >
              Yea, sorry it took so long. Was busy rebuilding a crashed disk.
              >Try just giving it read access to everyone. Or make the Apache user a
              >member of the group which owns the file and give the file group read access.
              >>
              >Of course, you could also make the apache user the owner of the file.
              >>
              >--
              >============== ====
              >Remove the "x" from my email address
              >Jerry Stuckle
              >JDS Computer Training Corp.
              >jstuck...@attg lobal.net
              >============== ====
              >

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...