Question
How to change PHP settings for one or all domains via command line(cli)?
Answer
- Connect to Plesk server using SSH as root user.
- Copy system php.ini to a new location:
# cp -a /etc/php.ini /var/custom-php-settings.ini
- Edit new file
/var/custom-php-settings.ini
and set desired options. - Create backup of Plesk database:
# plesk db dump psa > /root/psa.`date +%F.%s`.sql
- Apply
custom-php-settings.ini
file.
For one domain:# plesk bin site --update-php-settings example.com -settings /var/custom-php-settings.ini
For all domains:
Note: depending on number of domains this command can require long time to finish (more than 20 minutes).
# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e"select name from domains" | grep -v name |while read i; do plesk bin site --update-php-settings $i -settings /var/custom-php-settings.ini; done
Note: To register additional directives, add them to a separate file (e.g. add.ini) and apply it via the command below:
# plesk bin site --update-php-settings example.com -additional-settings /var/add.ini