LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > PHP File Writing Permissions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-09-2010, 02:48 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
Default PHP File Writing Permissions

Hi,

I can't seem to get this right.

When a script needs write access to a folder, for example for sessions or error logs, in apache I simply chown-ed them apache:apache and left them chmod 755.

Now with Litespeed, I can't figure out who executes the script.

In the server-wide settings I have:

Running As user(nobody) : group(nobody)

In the VH:

ExtApp Set UID Mode DocRoot UID

The owner of the docroot of that VH happens to be lsadm:lsadm

So I figured by either making the folder I intend to have PHP write in owned by nobody:nobody or lsadm:lsadm I'd be able to write in it when it's chmod 755. But somehow, I need to up that to 777 for it to work. And I don't like 777.

How can I figure out who runs the PHP process and should therefore be the owner of a folder in order to write to it?

What are the recommended ownership settings for LSWS?
Reply With Quote
  #2  
Old 06-09-2010, 03:01 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
I just found out that get_current_user = lsadm and getmyuid is 100, which in /etc/passwd equates to lsadm indeed. So if the script is run by lsadm, which can't the script write to a file owned by lsadm?
Reply With Quote
  #3  
Old 06-09-2010, 04:45 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,226
I did some tests locally, to enable

Quote:
VH:
ExtApp Set UID Mode DocRoot UID
need define a vhost level lsphp5 ExtApp first, say "lsphp5_vh" as its name.

then in vhost "Script Handler", select this lsphp5_vh to handle php.

if select lsphp extApp defined in server level, lsphp will run as server uid/gid, i.e., nobody in this case.
Reply With Quote
  #4  
Old 09-15-2010, 03:41 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
Hi,

This issue is still present.

I have exactly what you say, with a VHost level script handler which has a name different from the default. It handles PHP. The DocRoot UID is owned by lsadm:lsadm and a file further down the document tree is also owned by lsadm:lsadm

In the PHP script I echo get_current_user() and this confirms it's lsadm. The script tries to write to a cache folder again owned by lsadm:lsadm but it can't. Only when I chmod the cache folder recursively 777 it works. 755 doesn't work either.

What can I be overlooking?
Reply With Quote
  #5  
Old 09-15-2010, 10:08 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,226
echo umask() while echo get_current_user()
Reply With Quote
  #6  
Old 09-19-2010, 06:57 AM
mmaama mmaama is offline
New Member
 
Join Date: Sep 2010
Posts: 1
Try compiling Litespeed with phpsuexec, i had the very same issue and that's the way i fixed it.
Reply With Quote
  #7  
Old 09-21-2010, 09:29 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
Originally Posted by J.T. View Post
In the PHP script I echo get_current_user() and this confirms it's lsadm. The script tries to write to a cache folder again owned by lsadm:lsadm but it can't. Only when I chmod the cache folder recursively 777 it works. 755 doesn't work either.
Does your server use a special secure kernel? Or something special with PHP? Sohusin?

try
Code:
sudo -u lsadm touch test_file
under that directory, see if it has permission issue or not.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:25 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.