Home >Backend Development >PHP Problem >What to do if the php file does not have permissions

What to do if the php file does not have permissions

藏色散人
藏色散人Original
2022-11-10 09:37:292710browse

Solution to the problem that the php file does not have permissions: 1. Use the "ls -l ./[target_dir]" command to check the permissions; 2. Set the entire directory through "chown -R apache:apache [target_dir]" 3. Execute the "sudo -u apache git reset --hard 977e75b" command.

What to do if the php file does not have permissions

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if the php file does not have permission?

PHP reports file_put_contents failed to open stream: Permission denied in xxxxx on line 2

Use the command to check the permissions: ls -l ./[target_dir]

What to do if the php file does not have permissions

The permissions of this file have become root, not apache anymore.

Because git is installed in the project, git is executed under the root user. This should be the reason.

Solution:

Set permissions on the entire directory first chown -R apache:apache [target_dir] (restore permissions to apache)

Then every time you execute the git command, use the apache user to execute sudo -u apache git reset --hard 977e75b

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if the php file does not have permissions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn