Jump to content

Apache cannot read directory but permissions are correct


Recommended Posts

Hi guys, hope you can help me with this one. My doc root is /home/httpd/html. I have a file called tmp.php in that directory.

 

<?php
ini_set("display_errors", "On");
error_reporting(E_ALL);


exec('ls /home/kannel/smslogs/', $arrOutput, $intReturn);
echo "<pre>";
var_dump($arrOutput);
var_dump($intReturn);
?>

 

The permissions for smslogs directory is as follows:

drwxr-xr-x    4 kannel  kannel      4096 Apr 21  2005 smslogs

 

The code runs well in the console when I type "php tmp.php" but it doesn't work when I run it in the webserver "http://192.168.40.3/tmp.php"

 

Output in console:

Content-type: text/html

X-Powered-By: PHP/4.3.3

 

<pre>array(3) {

  [0]=>

  string(5) "globe"

  [1]=>

  string(5) "smart"

  [2]=>

  string(9) "smart.log"

}

int(0)

 

Output in browser:

array(0) {

}

int(1)

 

It seems the problem is permissions but apache should be able to read the directory because the permission for "others" in smslogs directory is r-x. Any ideas? Thanks!

its because command line path is different with http path or ur path in the browser.....do not use complete path like /home/kannel/smslogs

u use relative path....

 

e.g.

if ur tmt.php is in /home/kannel/scripts

use "ls ../smslogs"

 

hop ds helps....

Hi thanks for the suggestion, but I've used exec before with absolute paths and I didn't encounter any problems. Infact as a test, I replaced "/home/kannel/smslogs/'" with "/home/kannel/" and amazingly it worked which only added to my confusion, because it would mean that the smslogs directory is the problem, but this directory is readable by everyone (see first post for smslogs directory permissions). Also, I replaced ls with /bin/ls.

 

Here's the result of my test when I replaced "/home/kannel/smslogs/" with "/home/kannel/":

 

array(139) {

  [0]=>

  string(2) "~."

  [1]=>

  string(17) "02admucmp-jmx.sar"

  [2]=>

  string(26) "02admucmp-jmx.sar-20060113"

  [3]=>

  string(26) "02admucmp-jmx.sar-20060713"

  [4]=>

  string(26) "02admucmp-jmx.sar-20060921"

  [5]=>

  string(33) "02admucmp-jmx.sar-working11022005"

  [6]=>

  string(17) "03admucmp-ejb.jar"

  [7]=>

  string(26) "03admucmp-ejb.jar-20060113"

...

...

...

 

The permissions for kannel directory is as follows:

drwxr--r--  44 kannel  kannel      8192 Sep 13 14:10 kannel

 

I still can't understand why php could not read the smslogs directory.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.