Sam's Tech Blog

You can check out any time you like, But you can never leave!'

2019-10-01

PHP change script

A Bash script for changing PHP.ini limits.

PHP change script

#!/bin/bash
# script to increase default php.ini size settings in Debian based servers
cd /etc/php/
echo "Check PHP limits for default 2M settings."
grep -r '2M' * .
echo "Change PHP limits to 100M"
echo ""
echo ""
read -n 1 -s -r -p "Press any button to continue. Press CTRL+C to abort."
echo ""
find . -type f | xargs sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/g'
find . -type f | xargs sed -i 's/post_max_size = 8M/post_max_size = 100M/g'
echo "Done"
echo ""
echo "Restart Apache & PHP"
echo "" /etc/init.d/apache2 restart
/etc/init.d/php7.0-fpm restart
/etc/init.d/php7.1-fpm restart
/etc/init.d/php7.2-fpm restart
/etc/init.d/php7.3-fpm restart
/etc/init.d/php7.4-fpm restart