Solve problems arising from new SELinux security levels

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.