Created
July 18, 2018 09:19
-
-
Save gustavomcarmo/327038e0c4034da4b7324ecc1182169b to your computer and use it in GitHub Desktop.
Shell script to define the post_max_size and the upload_max_filesize values in the php.ini file.
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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "One parameter expected:" | |
echo "- the new size limit (in Mb)" | |
exit 1 | |
fi | |
SIZE_IN_MB=$1 | |
if [[ ! $SIZE_IN_MB =~ ^[0-9]+$ || $SIZE_IN_MB -eq 0 ]]; then | |
echo "$SIZE_IN_MB is not a positive integer" | |
exit 1 | |
fi | |
setValue() | |
{ | |
PHP_PARAM=$1 | |
sed -ri 's/^('$PHP_PARAM' = ).*$/\1'$SIZE_IN_MB'M/1' /etc/php/7.2/apache2/php.ini | |
if [ $? -ne 0 ]; then | |
echo "Error on setting the $PHP_PARAM value" | |
exit 1 | |
fi | |
echo "Parameter $PHP_PARAM set to $SIZE_IN_MB" | |
} | |
setValue "post_max_size" | |
setValue "upload_max_filesize" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment