简体   繁体   中英

Trouble setting chmod in WordPress

Basically I am creating a theme for my blog and I need to set the customcss.css to writable 777 so that when I change the design in the backend it writes to this file.

Everything works 100% when I set the chmod to 777 manually, but when I try to set the chmod to 777 when activating it display this error message:

Warning: chmod(): Operation not permitted in /var/www/vhosts/domainname.com/wptest/wp-content/themes/ctheme/ThemeFunctions/th‌​emeinstall.php on line 74

The code I am using is as follows:

$rootpage = get_theme_root();
chmod($rootpage . '/ctheme/css/customcss.css', 0777);

I have searched this website and unfortunately found nothing similar. What am I doing wrong?

When you execute the command manually, you are a user in the shell that is allowed to change the mode.

When you write the php function chmod into the script, it will be executed by another user, the user that is executing PHP.

Because that user is not allowed to change the mode of the file. That is why you see the error.

Unless you do not change the user that is executing PHP (to change the user that is then finally changing the mode), this error will not go away.

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