CentOS6 weird file permisisons behavior.

I don’t usually write much here, but I wanted to post something about this since it took me hours to find a solution. A few weeks ago I was working on upgrading a clients server with our new web application and after copying everything over PHP kept giving me a Permission Denied error for the CakePHP database.php file. What was weird was the permissions looked fine and hadn’t changed from the previous version. After a while of messing with the permissions I ended up with the entire webroot folder at 777. Same error. After even more Googling I found a single entry on StackOverflow (unfortunately I don’t have the link any longer) that mentioned deleting and recreating the file. BINGO! Delete and recreate the file to solve a permissions issue! Weird! What I ended up doing was moving the file and using `cat` to copy it. The contents of the file were identical, the permissions were identical, but no more permission denied error.