Last active
May 24, 2017 15:51
-
-
Save dhaupin/1f7ac8c7369bc60f385430e449a611eb to your computer and use it in GitHub Desktop.
Bash functions to Increase/decrease WHM backend PHP limits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cyan=$(tput setaf 6) | |
bold=$(tput bold) | |
reset=$(tput sgr0) | |
whm-max() { | |
# Boosts WHM power for exports/imports | |
if [ -z "$1" ]; then | |
vars="3000" | |
else | |
vars=$1 | |
fi | |
mem="512M" | |
exe="2400" | |
input="2400" | |
size="150M" | |
post="150M" | |
path="/usr/local/cpanel/3rdparty/etc/php.ini" | |
sed -in --follow-symlinks "s/[; ]*max_input_vars = [0-9].*/max_input_vars = ${vars}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*memory_limit = [0-9A-Za-z].*/memory_limit = ${mem}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*max_execution_time = [0-9].*/max_execution_time = ${exe}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*max_input_time = [0-9].*/max_input_time = ${input}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*upload_max_filesize = [0-9A-Za-z].*/upload_max_filesize = ${size}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*post_max_size = [0-9A-Za-z].*/post_max_size = ${post}/" ${path} | |
/usr/local/cpanel/bin/install_php_inis | |
/scripts/restartsrv_cpanel_php_fpm | |
php -v | |
printf "${cyan}${bold}Raised WHM max_input_vars to ${vars}${reset}\n" | |
printf "${cyan}${bold}Raised WHM memory_limit to ${mem}${reset}\n" | |
printf "${cyan}${bold}Raised WHM max_execution_time to ${exe} seconds${reset}\n" | |
printf "${cyan}${bold}Raised WHM max_input_time to ${input} seconds${reset}\n" | |
printf "${cyan}${bold}Raised WHM upload_max_filesize to ${size}${reset}\n" | |
printf "${cyan}${bold}Raised WHM post_max_size to ${post}${reset}\n" | |
} | |
whm-min() { | |
# Resets WHM to defaults | |
vars="1000" | |
mem="128M" | |
exe="30" | |
input="60" | |
size="50M" | |
post="55M" | |
path="/usr/local/cpanel/3rdparty/etc/php.ini" | |
sed -in --follow-symlinks "s/[; ]*max_input_vars = [0-9].*/max_input_vars = ${vars}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*memory_limit = [0-9A-Za-z].*/memory_limit = ${mem}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*max_execution_time = [0-9].*/max_execution_time = ${exe}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*max_input_time = [0-9].*/max_input_time = ${input}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*upload_max_filesize = [0-9A-Za-z].*/upload_max_filesize = ${size}/" ${path} | |
sed -in --follow-symlinks "s/[; ]*post_max_size = [0-9A-Za-z].*/post_max_size = ${post}/" ${path} | |
/usr/local/cpanel/bin/install_php_inis | |
/scripts/restartsrv_cpanel_php_fpm | |
php -v | |
printf "${cyan}${bold}Raised WHM max_input_vars to ${vars}${reset}\n" | |
printf "${cyan}${bold}Raised WHM memory_limit to ${mem}${reset}\n" | |
printf "${cyan}${bold}Raised WHM max_execution_time to ${exe} seconds${reset}\n" | |
printf "${cyan}${bold}Raised WHM max_input_time to ${input} seconds${reset}\n" | |
printf "${cyan}${bold}Raised WHM upload_max_filesize to ${size}${reset}\n" | |
printf "${cyan}${bold}Raised WHM post_max_size to ${post}${reset}\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment