Linux, Apache cannot create directories and files using PHP

Source: Internet
Author: User

A problem that has wasted hours of my time is simple.
A simple code

$dir = "temp";
mkdir ($dir, 0755);

Prompted me to permission denied.

I tried to change the parent folder permissions, recreate the folder, change the permissions, move the file, and replace the owner of the folder. Not at all. This mistake is always lingering. The underlying weaknesses of the Linux system are reflected.

Finally, in a friend's reminder, shut down the SELinux. The mistake was gone.

My God, my precious time.

Warning

Don't know how to close SELinux?

Under/etc/sysconf There is a selinux file, use VI to open, change the value of the SELinux item in it.
selinux=disable Disable SELINUX
Selinux=enforcing Use SELINUX
Selinux=permissive uses SELINUX to log errors only.

Remember to reboot.

If you do not reboot, with # Setenforce 0, you can temporarily set the SELinux to permissive mode. Remember to use the root user.
Then use # setenforce 1 This command will set SELinux to enforcing mode.

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.