Skip to content

Instantly share code, notes, and snippets.

@terremoth
Last active October 20, 2021 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terremoth/2ca3b3ad56b5c92b5d54741dbc9a4632 to your computer and use it in GitHub Desktop.
Save terremoth/2ca3b3ad56b5c92b5d54741dbc9a4632 to your computer and use it in GitHub Desktop.
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