Jump to content

[SOLVED] Can PHP 8 upgrade cause problems with folder ownership/permissions?


modifiedcontent
 Share

Recommended Posts

After upgrading to PHP 8 I now get errors like this in one of my sites:

Unable to load Modules
Unable to create directory /home/myusername/public_html/mywebsite/site/assets/cache/FileCompiler/site/modules/JquerySelectize/

...and trying to clear caches:

Fatal Error: Uncaught Error: Class "CacheControlTools" not found in site/modules/ProcessCacheControl/ProcessCacheControl.module:284

Other sites were mostly fine now, including Cache Control, but earlier I've had several other issues with suddenly unreachable folders here and here and here after making PHP and Apache changes via EasyApache. 

Are these known issues? Does anyone recognize them? How can I fix them? 

I've tried triple-checking/resetting folder ownership/permissions, but can't find a definitive guide what those settings should be and am probably only making things worse. 

 

Link to comment
Share on other sites

  • modifiedcontent changed the title to Can PHP 8 upgrade cause problems with folder ownership/permissions?

I don't think a PHP update can have an impact on folder permissions. More likely this is an Apache and/or PHP-FPM missconfiguration issue.

9 hours ago, modifiedcontent said:

I've tried triple-checking/resetting folder ownership/permissions, but can't find a definitive guide what those settings should be and am probably only making things worse.

File/Folder permissions are documented here https://processwire.com/docs/security/file-permissions/ 

Link to comment
Share on other sites

Edit: Solution is at the end of this comment, after a few educational dead ends. ?

@gebeerI use EasyApache4; just standardized automated upgrade/changes on a VPS with a few PW websites that have been running fine for years. I have not improvised anything, not made any manual configuration changes.

Of course there is a misconfiguration somewhere. I'm trying to find out where and created this thread to find out if anyone had seen something similar after PHP config changes. Here's one via a Google search - also uses CentOS, but with Apache vs Nginx issue, so problably not relevant. 

Thanks for the file permissions link. I'll see if I can fix my problem with that, but they're not clearcut instructions what ownership and permissions each folder/file should have. I see my Apache now runs as 'nobody'; I think it used to be/should be 'myusername'? My PW sites were installed as 'myusername' and all folders/files are owned by that 'myusername'. 

Edit: EasyApache apparently "updates" user settings or PHP handlers (?) and you have to turn that off? Here is a possible way to make Apache run as 'username' instead of 'nobody', I think, from 2012, so not risking that one...

WHM has Apache mod_userdir Tweak where only 'DefaultHost (nobody)' has 'Exclude Protection' selected and all my other hosts/website have 'myusername'. No clue what to do with that info. Can I change DefaultHost to 'myusername' anywhere?

There's this file on my CentOS server:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#   DO NOT EDIT. AUTOMATICALLY GENERATED.  USE INCLUDE FILES IF YOU NEED TO MAKE A CHANGE
#   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#   Direct modifications to the Apache configuration file WILL be lost upon subsequent
#   regeneration of this configuration file, or an Apache update.
#
#   To have your modifications retained, you should create/edit administrator-specific
#   include files:
#
#       /etc/apache2/conf.d/includes/pre_main_global.conf
#       /etc/apache2/conf.d/includes/pre_virtualhost_global.conf
#       /etc/apache2/conf.d/includes/post_virtualhost_global.conf

...

# These are hard-coded values that are required by cPanel & WHM
PidFile /run/apache2/httpd.pid
User nobody
Group nobody

...

Tried changing 'nobody' to 'myusername' in pre_main_global.conf, empty file with only this:

User myusername
Group myusername

And then run these two commands from root in SSH to rebuild httpd.conf and restart Apache:

/usr/local/cpanel/scripts/rebuildhttpdconf

/usr/local/cpanel/scripts/restartsrv_httpd

One site that was giving me nasty 500 server errors is suddenly back, but that could also be because I changed permissions on all folders to 777 - bad for security... <?php echo exec('whoami'); ?> is still giving me 'nobody' as Apache user. Apache mod_userdir Tweak in WHM still has 'DefaultHost (nobody)'.

Another clue here: 'If you install the suEXEC module, the system executes PHP applications as the user that owns the VirtualHost that served the request. If you uninstall the suEXEC module, the system executes PHP applications as the nobody system user.'

mod_suexec is an Apache Module that can be enabled in EasyApache4. Enabling that seems to fix most issues I had. <?php echo exec('whoami'); ?> now give the correct 'myusername'.

Edit: There is also another Apache Module mod_suphp that may be required to fix issues with some scripts.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • modifiedcontent changed the title to [SOLVED] Can PHP 8 upgrade cause problems with folder ownership/permissions?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...