Applicable to:
- Plesk for Linux
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
Comments
2 comments
/etc/php.ini does not exist. That isn't where php.ini lives in a plesk environment. Also, there are separate php.ini's for each version of php on the system so using one custom.php.ini will not suffice.
/etc/php.ini only serves as a template here. You can create new custom php.ini from scratch, or use any php.ini you want. Of course, you are correct that applying the same php settings for different php versions is not recommended. In that case, you should apply the settings only for the chosen domains.
Please sign in to leave a comment.