logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Php reports Read-Only File System
Author
cipocip



Joined: 06 Sep 2013
Posts: 3

PostPosted: Fri 06 Sep '13 20:02    Post subject: Php reports Read-Only File System Reply with quote

Hello

I am a user (not root) on a Red Hat Enterprise Linux server. I am unable to use PHP (Apache 2.0) to write files with fwrite to my public_html. Also, when I try something like shell_exec('rm some_file'), I get the error message: "Read-Only file system". To isolate the problem, I chmod the public_html to rwx for ugo, but that didn't solve the problem. It's only through PHP (web user nobody) that I can't write to my public_html directory.

What migh be causing this ?

Thanks.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Sat 07 Sep '13 18:37    Post subject: Reply with quote

shell_exec has nothing to do with the permission of the folger. shell_exec tries to execute the file. SO that file needs to bee 0777.

from the docs
Code:

shell_exec — Execute command via shell and return the complete output as a string


What are you trying to do? just cerate a text file content in it?
Back to top
cipocip



Joined: 06 Sep 2013
Posts: 3

PostPosted: Sat 07 Sep '13 19:51    Post subject: Reply with quote

Hello James,

In a nutshell, I am unable to write (or delete) any file in public_html through PHP.

I did set the permissions of "some_file" to o+rwx in my example - shell_exec('rm some_file'). When I redirect stderr to stdout, I get the important message/clue: "Read-Only file system". I am very puzzled by that, because all the permissions of the folder and files in it are set to 777, and public_html is obviously not read-only. If it was a permission problem, it should warn me: "Permission denied".

Another attempt of writing anything at all using fwrite failed as well.

I must add that I have tested all my scripts on a separate Apache/Ubuntu installation on my home computer, and they work as they should, no syntax errors.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Sat 07 Sep '13 22:11    Post subject: Reply with quote

Can you please post a snippet? I need to try that out Wink
Back to top
cipocip



Joined: 06 Sep 2013
Posts: 3

PostPosted: Sat 07 Sep '13 23:10    Post subject: Reply with quote

Sure, but you won't be able to learn much from it since you don't have access to the actual Red Hat server. Here is one test file:

Code:
<?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "This is a test\n";
fwrite($fh, $stringData);
fclose($fh);
?>


Here is another one:

Code:
<?php
$output=shell_exec('rm file.txt 2>&1');
echo "<pre>$output</pre>";
?>


The output of the first test file is: can't open file (not very helpful), and for the second file:
Code:
rm: cannot remove `file.txt': Read-only file system
The permissions of public_html are: drwxrwxrwx. And of course, file.txt exists, and I can remove it as a regular user.

If you have any diagnostic tests that I could try, I am really curious to find the explanation for this. Somehow the filesystem appears as read-only to the outside world (user nobody).
Back to top


Reply to topic   Topic: Php reports Read-Only File System View previous topic :: View next topic
Post new topic   Forum Index -> Other Software