Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Change and Reconfigure PHP ini (from FPM) via shellscript
#!/usr/bin/env sh
# The FPM ini file, and not the CLI one
ini_file=$(php -i | grep "Loaded Configuration File" | awk -F ' => ' '{print $2}' | sed 's/cli/fpm/g')
echo $ini_file
sudo sed -i 's/memory_limit\s*=.*/memory_limit = 256M/g' $ini_file
cat $ini_file | grep memory_limit
sudo sed -i 's/upload_max_filesize\s*=.*/upload_max_filesize = 3G/g' $ini_file
cat $ini_file | grep upload_max_filesize
sudo sed -i 's/max_file_uploads\s*=.*/max_file_uploads = 300/g' $ini_file
cat $ini_file | grep max_file_uploads
sudo sed -i 's/post_max_size\s*=.*/post_max_size = 3G/g' $ini_file
cat $ini_file | grep post_max_size
sudo sed -i 's/max_input_time\s*=.*/max_input_time = 3600/g' $ini_file
cat $ini_file | grep max_input_time
echo 'Restarting Nginx and FPM'
sudo systemctl restart nginx
sudo systemctl restart php$(php -r 'echo substr(phpversion(), 0, 3);')-fpm
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment