I am using Apache server on Linux Fedora 17. I have one PHP code which creates a .ini file. If I create the .ini file by running PHP code through Apache web server then rest PHP code files are able to read the .ini file data as its owner is Apache. But if I run the PHP code from Linux terminal and generate that .ini file then rest PHP code files are not able to read the file data as the owner is root. I tried changing group and file owner of .ini file from root to Apache from terminal but still it is not working.
You are running the php script as 'root' user, which is why the .ini file is getting created with root ownership.
Even if the file is getting created with 'root' as its owner, the other 'php code files' should be able to read it since it will, in all probability, have read permission for 'others'. So here, you need to check the permissions of the directory in which the .ini file is getting created.