The PHP fopen function returns false

Source: Internet
Author: User
Tags php error

apache2.4.6 php 7.2.2 installed with Yum returns False when opening a file using the fopen () function after proper installation

Baidu for three different reasons

1, directory or folder permissions reasons

(You can set the highest permissions with the Chmod-r 777 root folder)

2. Open File path error

3, open mode error (W,R,A), etc.

Determined not to have the above error

Add a PHP error report manually

// Error handler function function customerror ($errno$errstr) {          echo ' <b>error:</ b> [$errno$errstr";} // Set Error Handler Set_error_handler ("Customerror");

The error message returned is

Failed to open Stream:permission denied

Prove no permissions

Switch to read-only mode to open normally

Guess it's php that restricts permissions.

Search Open_basedir in php.ini view configuration, default is commented out, that is, there is no Limit permissions

Finally on the internet all kinds of Baidu

found that the default installation of the CentOS system has selinux rights management, and is enabled by default

Baidu has a bit of selinux, the introduction of most of them are directly closed, configuration seems to be very troublesome

Then it's still closed.

Vim/etc/selinux/conf

Can see

selinux= Enforcing

Revision changed to

Selinux=disabled

Can

Restarting the server

Write file again normal

The PHP fopen function returns false

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.