There is a file(644, owner:apache) that I can't delete it using a PHP script with unlink function.
I can't figure it out why unlink fails to delete this file.
BTW, I have tried fclose it before unlink it. Unfortunately, it still didn't work.
“drwxrwxrwx 2 apache apache” apache have write access to the directory.
Does apache have write access to the directory that the file is in ?
What server operating system are you using? It's possibly SELinux causing this - if you have an OS with that installed, look in /var/log/secure or maybe /var/log/audit/audit.log for mentions of the file you are trying to unlink.
Sorry, guys. Problem solved.
It turns out the other mistake in my script have caused the problem. But I still learned a lot in this discussion. Thanks.