In the ora Core 3 Linux release version, when you run files or directories of PHP or similar scripts, the following exception may occur: "failed to open stream: permission denied in... ". This easily reminds us of permission issues. We will set the permission for this file or directory to 777 as usual, but unfortunately, this may not solve this problem in this version.
This is because the new SELinux kernel only allows apache users to perform such operations only in the/tmp directory. There may be other possibilities and causes ), to solve this problem, you must disable the security-level features of SELinux and allow apache users to operate on other directories. See the following detailed steps and illustration:
The following PHP code is available:
If (! File_exists ("count") // if the file count does not exist {$ file = fopen ("count", "w + "); // create the count file and write it to fwrite ($ file, "000001"); // write fclose ($ file); // close the file} |
An exception occurs after running:
Warning: fopen(count): failed to open stream: Permission denied in /var/www/html/count.php on line 4Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/html/count.php on line 5Warning: fclose(): supplied argument is not a valid stream resource in /var/www/html/count.php on line 6 |
Choose Application> system Settings> Security Level ":
After confirming the modification, remember to restart the firewall and Apache server. Run the above Code again and the program runs normally.
Related Articles]
- Use Linux (SELinux) with enhanced security)
- Generate SELinux from scratch
- SELinux "unix_chkpwd" Security Bypass Vulnerability