The issue was that PHP was running not as root user changing the user to root actually solved the problem. For those who wants to know how to Switch PHP user to ROOT. Just Follow the following steps.
Step 1: Open httpd.conf
Step 2: Search for User/Group
Step 3: Under it you will find
User (your default user name)
Group (your default group name)
Change it to root so that your file looks like this:-
User root
Group root
Step 4: Restart Apache
PS:Switching PHP to work as root user is not suggested for production servers. Please change this only if you are sure about this.