troubleshooting Question

Managing PHP/Apache Users & Uploading Files

Avatar of Paul Konstanski
Paul KonstanskiFlag for United States of America asked on
PHPApache Web Server
1 Comment1 Solution394 ViewsLast Modified:
I am trying to understand how the Linux user works and interacts with a PHP Script running on an Apache server.  This question has three part to it.  

I have a very simple script that prints the userinfo on screen:
$uID = posix_geteuid();
$dummy = posix_getpwuid($uID);
print_r($dummy);

On Server "A" It yields this result:
 [name] => apache [passwd] => x [uid] => 48 [gid] => 48 [gecos] => Apache [dir] => /var/www [shell] => /sbin/nologin
(PhpInfo shows: Server API  Apache 2.0 Handler, this is a server on which I have total control. )

On Server "B" the same script yields this result:
[name] => ixj.arrowone [passwd] => x [uid] => 613764 [gid] => 15020 [gecos] => ixj.arrowone [dir] => /home/users/web/b2197/ixj.arrowone [shell] =>
(PhpInfo shows: Server API  CGI.  This is a hosted server on where I'm leasing space. )

What I'm seeing here is that the php.ini settings control the user that accesses the php scripts when coming in thru the WWW interface.  That makes sense.  Now my questions.

#1. Are there advantages/disadvantages of the user being "Apache" verses an assigned username (i.e. like on server "B")?  

#2. Is there a way to change the user from within the phpScript itself or only thru the php.ini?  

#3. I'm having an issue with files I upload via FTP as only being accessible when I change the permissions to 777.  I'd rather not give the "world" write access, but it appears that is the only way I can do that.  Does the "apache" user require "world" access to display files thru the Web browser?

Thanks.

ASKER CERTIFIED SOLUTION
flubbard

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros