I just was able to fix this.Actually php exec('whoami') was working but the httpd command was not. So after allowing apache to run commands with visudo and then ##Defaults requir... [by hercent]
on 01/12/2013 – Made popular on 01/12/2013
I made changes to the httpd.conf file. How do I reload the new config changes without restarting the Apache 2 web server under Debian / CentOS Linux operating systems?Read answer to: "Apache 2: Reload HTTPD Configuration File Without Restarting Apache Config Changes"
I have a cron job that runs a PHP script and creates files (images). But the cron job is running as me (being me my own username), not apache, nobody, httpd, www... and all the files created belongs to this user.
If I run the the same script through a browser, it runs as apache.