简体   繁体   中英

How to fix problem with user permissions in CentOS7, Apache and php script

I faced strange problem wher ran Apache server and php7.1 script.

PHP doesn't have it's root folder write-access. It's necessary for my task to have those permission. I start httpd service on my system, then run my script, and it doesn't work because of lack of permissions. Where do i have to change those permissions?

This is for Linux Server running Apache2, PHP 7.1 here you can see my processes (sorry cannot attach photo) (php is running under apache user)

Also here .php shows where my root folder is (/var/www/html)

and here is my folder with permissions: drwsrwsrwt+ 3 apache apache 103 html

As you can see I even tried to give chmod 7777 to that folder /var/www/html, but it still didn't work!

Then, i desided to recursively add permissions to root folder (/var/www).

i used .php testfile to check what user runs apache and also to chek root directory of script

echo `whoami`;
echo getcwd() . "\n";
$filename = '/var/www';
if (is_writable($filename)) {
    echo 'folder /var/www is ready to be written' . "\n";
} else {
    echo '...cant be written';
};

I have that output:

apache /var/www/html folder /var/www/html not ready

another check of write permissions in another script (not mine) tells the same

I really stuck with that, please, help)

Thank you in advance!

I bet it is because of selinux , disable it by editing

/etc/selinux/config

and make sure it has

SELINUX=disabled

https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

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