EDIT 01 UPDATE:
ERROR Showing UP Warning: mkdir(): Permission denied in
/var/www/html/projeto01/index.php on line 7 Sucess. Dir Created
EDIT 02
Change to FEDORA and is working.
Thank you guys
before submitting this topic I read and tried all the topics here. No success.
The environment is working great until here. Php 7.4, Apache, Mysql Workbench, Atom... i can code and select from database, everything was great.
The code is working with no error execpt it did not create the directory. :/
If i create the dir manually, return the message that it already exist.
After read a lot of topics and get help from facebook.
I did change on group polices. Not worked.
chmod on the folder, not worked.
On CENTOS the apache user is APACHE instead www:data
ls -l /var/www return:
drwxr-x---. 2 apache apache 6 Nov 16 13:19 cgi-bin
drwxrwxrwx. 3 apache apache 39 Mar 19 13:54 html
ls -l /var/www/html return:
-rw-r--r--. 1 root root 86 Mar 19 00:09 info.php
drwxrwxrwx. 2 apache apache 23 Mar 19 13:58 projeto01
ls -l /var/www/html/projeto1 return:
-rwxrwxrwx. 1 root root 148 Mar 19 15:14 index.php
Thanks for the help!
My code is:
> <?php
$name = "images";
if (!is_dir($name)) {
mkdir($name);
echo "Sucess. Dir Created.";
} else {
echo "Dir already exist. $name";
}
?>
My Answer:
It seems like the issue might be related to the permissions of the directory where you are trying to create the file or folder.
Since you are using CentOS, the Apache user is typically `apache` instead of `www-data` as in some other distributions.
You mentioned that you tried changing the group policies and using `chmod` on the folder, but it didn't work.
One thing you can try is to change the ownership of the directory to the Apache user. You can do this by running the following command:
sudo chown -R apache:apache /var/www/html/projeto01
This will change the ownership of the `projeto01` directory and all its contents to the Apache user.
After running this command, try running your PHP code again to see if it can create the file or folder successfully.
If you continue to experience issues, you may want to check the SELinux settings on your CentOS system, as SELinux can sometimes interfere with file and directory permissions.
I hope this helps! Let me know if you have any other questions.
Rate this post
3 of 5 based on 7944 votesComments