SOLVED MPM Pre_fork to Worker changes file permissions

itmonitor

Well-Known Member
Apr 10, 2014
83
15
83
cPanel Access Level
Root Administrator
Hello,

History: we have Wordpress website that runs on a (newly installed) VPS server, on Apache/2.4.25 (cPanel), CENTOS 7.3 x86_64 virtuozzo – cPanel & WHM 64.0 (build 32) and PHP7.0.

Issue: While checking which Server MPM would reduce the website load speed, we noticed that when changing from the preselected pre_fork to worker, the server file permissions were changed. This happened at least concerning the website files, and as a result we are unable to update Wordpress, install or uninstall any plugin because Wordpress is unable to write/change the files in the server - here you have a description of the issue:
- Removed -

To try to solve this issue, we moved back to pre_fork MPM, but the file permission issue persists. The hosting company will run a file permission script to solve the issue, but I believe that this file permission change should not happen when enabling one or other MPM.

Please, let me know if you experienced any issue like this. Could this be an EasyApache4 bug?
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
here you have a description of the issue:
- Removed -
Hello,

It looks like the output was moderated. Could you provide some more details about what was changed, ensuring to exclude any real domain names or identifying information about your server?

Thank you.
 

itmonitor

Well-Known Member
Apr 10, 2014
83
15
83
cPanel Access Level
Root Administrator
Hello Michael,

Sorry if this post is a bit long but I want to share all informatin I gathered since May, to help you fix the issue.

Here you have the link to the descritpion of the issue - Removed Please Use Words to Explain Your Issue - . If this is moderated again, please google "Wordpress plugin installation: FTP credentials" by Christian Weiske.

This MPM file permission issue happened to me in end May with another VPS server (Virtuozzo, Centos 6.9, Apache 2.4), after changing MPM. At the time, the hosting company informed that "We have corrected the issue by running a permission fix script and also by changing the PHP handler."

----
Reproducing the present Issue:
1. Before changing from Server MPM Prefork into MPM Worker, the Wordpress install, uninstall, update features were working without issue.
2. After changing into MPM Worker, somehow the server file permissions were changed and I when I try to install a plugin/update Wordpress I get the error described in detail in the above article: "To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host." Check here screenshot - Removed Please Attach Images To Your Posts -
3. Even when I fill in the credentials fields, and check the SFTP, it will not proceed to uninstall/install/update plugins and Wordpress.
4. I moved back to MPM Prefork, but the file issue persists.
5. Presently the server is set to MPM Event, but the file issue persists.
6. The hosting company has run a script to chwon the server files, it does not fix this issue. They do not remember which PHP handler modification solved the same issue back in May.
---

The website is not broken and load quickly under 2.5s. Wordpress and the plugins are not able to write the files in the server.

The article by Weiske proposes a fix
Code:
define('FS_METHOD', 'direct');
that is not working, at least for me.

Even so, ideally when changing MPMs (Prefor, Worker, Event) the file permissions shoud not be modified in the server.

Hope this information helps CPanel to fix this bug.

If you need further testing, please, I am here to help you.

Any help to solve this issue is welcome.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
Hello,

It seems more likely related to the PHP handler (e.g. suPHP, DSO, CGI) as opposed to MPM worker/prefork. Could you browse to "WHM >> MultiPHP Manager" and confirm which PHP handler is associated with the version of PHP utilized by the affected domain name?

Thank you.
 

itmonitor

Well-Known Member
Apr 10, 2014
83
15
83
cPanel Access Level
Root Administrator
sure, here you have the screenshot diigo.com/item/image/5pj5q/ipn3 PHP7.0 is not associated to any handler. Which one should it be?

EDIT: sorry, the website in question is running over PHP 5.6. The PHP 5.6 Handler is set to cgi.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
  • Like
Reactions: itmonitor

itmonitor

Well-Known Member
Apr 10, 2014
83
15
83
cPanel Access Level
Root Administrator
Hello,

the hosting company managed to solve the issue...by installing a backup from before the day I changed MPM from Perfork into Workers. Nobody can tell me why the MPM change affected the file permissions. I would need to enable the suPHP handler and change it, but this could bring back the file permission issue. I believe that when changing MPMs in the server this file permission issue should not happen.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
Nobody can tell me why the MPM change affected the file permissions.
I'm not seeing anything that shows permissions on existing files were changed (e.g. /path/to/file.php changing from 0644 to 0666 permissions). It looks like it's more so an issue where WordPress can not manipulate existing files or directories because of the change to the PHP handler. Feel free to open a support ticket if you'd like us to take a closer look at the affected system.

Thank you.
 
  • Like
Reactions: itmonitor

itmonitor

Well-Known Member
Apr 10, 2014
83
15
83
cPanel Access Level
Root Administrator
It took me 15 days of research and tests in my spare time, but just found the right solution. I post the solution here to help others:

When fine tuning Apache through EasyApache4 for improving website load speed, I had enabled mod_pagespeed. On enabling it, it will automatically disable mod_ruid2 and mod_cgi (and enable other two modules). When disabling mod_pagespeed, it will not re-enable mod_ruid2 automatically - it will re-enable only mod_cgi. Without mod_ruid2 Wordpress will request the FTP credentials.

There is no need to hard code wp-config.php. Just enable mod_ruid2 manually, restart Apache and the FTP/file permission issue is solved. Wordpress and plugins now can be updated as usual and media uploaded to the Wordpress gallery. It works right away, at least on the server environment informed in my original post above.

EDIT: I just checked that when changing from MPM Prefork into Worker, it will disable mod_ruid2. When reverting from Worker to Prefork it will not enable mod_ruid2, causing the issue described in this post. In both cases, the key is to enable mod_ruid2.

Hope to have helped.
 
Last edited:
  • Like
Reactions: cPanelMichael