• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved How to update default open_basedir for all websites?

macandcheese

New Pleskian
Server operating system version
AlmaLinux release 8.8 (Sapphire Caracal)
Plesk version and microupdate number
Plesk Obsidian 18.0.52.3
Dear Plesk community,

TLDR: How can we update PHP's default open_basedir for multiple domains at once?

For all domains on our 10+ Plesk servers, we're trying to configure PHP's auto_prepend_file to intercept fatal errors and send them to cloud logging.
However, most of the domains also have PHP's open_basedir setting enabled for security.
To make auto_prepend_file work, open_basedir needs to be changed to {WEBSPACEROOT}{/}{:}{TMP}{/}{:}/path/to/prependedstuff/.

Every domain uses the default setting:
1686712262657.png

...and ideally what I'd do is change that default in a single location to update all domains at once. This however seems impossible, because:
  • PHP Settings > php.ini can't be used here, because every domain has a different {WEBSPACEROOT}.
  • Service Plan > PHP Settings > Update & Sync has no effect; existing domains' open_basedir doesn't get updated.
  • Restricted Mode Settings > PHP Settings similarly has no effect on existing domains.
Any ideas, like changing the psa database maybe? Thanks in advance.

Some additional details:
- Most servers use LiteSpeed
- Servers use a mix of fastcgi and php-fpm
 
1) Make a backup of the psa database

2) Update PHP configuration in database:
plesk db
Code:
> use psa;
> UPDATE `psa`.`PhpSettingsParameters` SET value='<your new complete open_basedir entry>' WHERE name LIKE 'open_basedir';
> quit;

3) Apply PHP settings to domains using "/usr/local/psa/bin/domain --update-php-settings <domain name>". For example:
plesk bin domain -l | while read domain_name; do /usr/local/psa/bin/domain --update-php-settings $domain_name; done
Depending on the number of domains, this can take a while to complete, probably around 1 to 2 seconds per domain.
 
1) Make a backup of the psa database

2) Update PHP configuration in database:
plesk db
Code:
> use psa;
> UPDATE `psa`.`PhpSettingsParameters` SET value='<your new complete open_basedir entry>' WHERE name LIKE 'open_basedir';
> quit;

3) Apply PHP settings to domains using "/usr/local/psa/bin/domain --update-php-settings <domain name>". For example:
plesk bin domain -l | while read domain_name; do /usr/local/psa/bin/domain --update-php-settings $domain_name; done
Depending on the number of domains, this can take a while to complete, probably around 1 to 2 seconds per domain.

One more question - is it also possible to (programmatically) update the defaults set in the following places?
  • Service Plan > * > PHP Settings > Update & Sync
  • Restricted Mode Settings > PHP Settings
 
Back
Top