Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

whoami in workspaces and chmod in php (also in workspaces)

When I type whoami in the workspaces console I get treehouse. However, if in index.php I echo either exec('whoami') or shell_exec('whoami') I get apache. Why is that? Also, I can't seem to figure out how to allow the use of the chmod function in index.php. It works fine in the console.

1 Answer

Seth Kroger
Seth Kroger
56,407 Points

Apache, the web server is what is running you PHP file through a PHP interpreter. It's a common setup to have apache run as it's own user, also named apache, for security and other reasons. This means it won't be able to read anyone else's private files, or modify their files. chown won't work, of course, because you have to be the file's owner to use it.