Web Hosting Forum | Lunarpages
News: July 14, 2008 - New Contest! - Submit Your WordPress Theme Designs, Win BIG!
June 30, 2008 - Submit Your Site for the July 08 Site of the Month Award!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 25, 2008, 05:47:33 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: file permission  (Read 879 times)
saeed
Spacescooter Operator
*****
Offline Offline

Posts: 38


« on: September 03, 2005, 10:28:39 PM »

Hi...
I have a problem in my dedicated server...
when i want writing to file I have permission error...
this is my code (for example):

Code:
$file_content =
"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
";

$input_file = dirname(__FILE__)."/../test.html";

$handle = fopen($input_file,"w");

fwrite($handle,$file_content);

fclose($handle);

and I have this error :

Warning: fopen(/home/irpna02/public_html/temp/../test.html): failed to open stream: Permission denied in /home/irpna02/public_html/temp/test.php on line 18

Warning: fwrite(): supplied argument is not a valid stream resource in /home/irpna02/public_html/temp/test.php on line 20

Warning: fclose(): supplied argument is not a valid stream resource in /home/irpna02/public_html/temp/test.php on line 22

please help me....i am confused....
is it probably suPHP problem ?
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #1 on: September 03, 2005, 11:41:51 PM »

Hello,

Apache is running as user nobody by default on dedicated servers with cPanel. So, you would need to ensure that nobody has write permission on the directory where you want to put the file.
Logged

Kind Regards,
Vlad Artamonov
saeed
Spacescooter Operator
*****
Offline Offline

Posts: 38


« Reply #2 on: September 04, 2005, 03:20:58 AM »

How can i found that ?
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #3 on: September 04, 2005, 07:57:41 AM »

Hi,

Login as root and type in the directory where files will go:

ls -al

You might see the following:

drwxr-xr-x   3 username  username    512 Sep  2 17:07 .
drwxr-xr-x  40 username  username  1024 Aug 29 06:10 ..
-rw-r--r--   1 username  username      0 Aug 27 01:07 file

The column at the beginning of each line is the file permissions (for the owner, the group, and everyone). The fist line shows the permissions for your current folder wich permissions will be set.

There are a few ways how to change folder permissions to allow php scripts to create files, I always recommend to change the group to which the folder belongs to and give the group write privileges to that directory:

chown username:nobody .
chmod g+w .

Now do "ls -l" again. The output should be like:

drwxrwxr-x   3 username  nobody    512 Sep  2 17:07 .
drwxr-xr-x  40 username  username  1024 Aug 29 06:10 ..
-rw-r--r--   1 username  username      0 Aug 27 01:07 file

Please let me know if you have any further questions.
Logged

Kind Regards,
Vlad Artamonov
saeed
Spacescooter Operator
*****
Offline Offline

Posts: 38


« Reply #4 on: September 05, 2005, 12:22:28 AM »

thank you...
but I want to write in my public_html folder...
the default permission for public_html is 750
is'nt it security risk to set it 755 or 777...
i heard that suphp solve this problem...is it correct ?
if yes how can i install it...
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #5 on: September 14, 2005, 03:01:34 AM »

I am not sure that there is a big difference between those two ways of the problem solving because in both cases you will create a potential security hole by allowing php scripts to put files in a directory. Can I ask you why do you need this capability?

In order to configure suPHP on your server you might ask systems administrators to do  this by email to dedicated@lunarpages.com as you have opted the Managed addon during the sign up process.
Logged

Kind Regards,
Vlad Artamonov
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM