简体   繁体   中英

Unable to create files/folders using php on Apache Web-Server

touch(): unable to create file /var/www/html/test.txt because Permission denied in /var/www/html/web_services/test.php on line 6.

The php script in question

<?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    echo exec("whoami");
    touch("/var/www/html/test.txt");
?>

Development environment is rhel8. I have tried setting the ownership to apache:apache with.

sudo chown -R apache:apache www

I even tried with setting permissions as 777 to the entire www directory recursively with

sudo chmod -R 777 www

Any thoughts are appreciated.

Open terminal and type

sudo chmod a+wr /var/www/html Type your password

You're done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM