Find the answer to your Linux question:
Results 1 to 2 of 2
hi ihave problem ,the apache server can not execute some codes from brawser,but the same code executed from terminal.this example <?php $filename="/root/Desktop/qu.txt"; $file=fopen($filename,"r"); $filesize=filesize($filename); $text=fread($file, $filesize); fclose($file); echo("filesize:$filesize bytes"); echo("<pre>$text<pre>"); ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    38

    apache problem


    hi
    ihave problem ,the apache server can not execute some codes from brawser,but the same code executed from terminal.this example
    <?php
    $filename="/root/Desktop/qu.txt";
    $file=fopen($filename,"r");
    $filesize=filesize($filename);
    $text=fread($file, $filesize);
    fclose($file);
    echo("filesize:$filesize bytes");
    echo("<pre>$text<pre>");
    ?>
    but another codes can executed in the browser. example
    <?
    $a=0; $b=0;
    for($i=0;$i<5;$i++)
    {
    $a+=10; $b+=5;
    }
    echo("at the of the loop a=$a and b=$b");
    ?>

  2. #2
    Just Joined! vigour's Avatar
    Join Date
    Oct 2007
    Posts
    68
    1. I doubt you will be able to open /root/Desktop/qu.txt with the apache user. By default the /root directory is accessed only by the root user.

    2. I suggest you put this file in a location readable by apache

    3. What distro are you using? If you are using RHEL, CentOS or Fedora, they come by SELinux enforced by default. This means that unless your file is in the httpd_sys_content_t context, you'll unlikely be able to read it.

    If that is the case as well you must as well execute:

    Code:
    chcon -t httpd_sys_content_t /var/www/html/qu.txt
    If qu.txt is in /var/www/html of course

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •