We help IT Professionals succeed at work.

Managing PHP/Apache Users & Uploading Files

Paul Konstanski
Last Modified: 2013-12-12
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);

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?


Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.