From f70df069b3d7b1b629b2655c9e29634090902065 Mon Sep 17 00:00:00 2001 From: Individual IT Services Date: Wed, 28 Aug 2013 23:32:42 -0700 Subject: Increased needed memory for APC to 512M + code cleanup - Increased the needed memory for APC to 512M as we often run into memory problems on our 256M box - fixed the RAM calculation to divide by 1024 and not 1000 - code cleanup (renaming variables and creating new to avoid magic numbers) --- etc/rc.php_ini_setup | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/etc/rc.php_ini_setup b/etc/rc.php_ini_setup index b6c2396..a108c62 100755 --- a/etc/rc.php_ini_setup +++ b/etc/rc.php_ini_setup @@ -27,6 +27,7 @@ # Set our operating platform PLATFORM=`/bin/cat /etc/platform` +MIN_REALMEM_FOR_APC=512 if [ -d /usr/local/lib/php/20090626 ]; then EXTENSIONSDIR="/usr/local/lib/php/20090626/" @@ -46,22 +47,35 @@ if [ -z "$AVAILMEM" ]; then AVAILMEM=`/bin/expr $MEM / 1048576` fi -# Calculate APC SHM size according -# to detected memory values -if [ "$AVAILMEM" -gt "135" ]; then - APCSHMEMSIZE="10M" -fi -if [ "$AVAILMEM" -gt "256" ]; then - APCSHMEMSIZE="20M" -fi -if [ "$AVAILMEM" -gt "384" ]; then - APCSHMEMSIZE="25M" -fi -if [ "$AVAILMEM" -gt "512" ]; then - APCSHMEMSIZE="30M" -fi -if [ "$AVAILMEM" -gt "784" ]; then - APCSHMEMSIZE="50M" + +# Get amount of ram installed on this system +REALMEM=`/sbin/sysctl hw.realmem | /usr/bin/awk '{print $2/1048576}' | /usr/bin/awk -F '.' '{print $1}'` +export REALMEM +export LOWMEM + +if [ "$REALMEM" -lt "$MIN_REALMEM_FOR_APC" ]; then + LOWMEM="TRUE" + echo ">>> WARNING! under $MIN_REALMEM_FOR_APC megabytes of ram detected. Not enabling APC." + echo ">>> WARNING! under $MIN_REALMEM_FOR_APC megabytes of ram detected. Not enabling APC." | /usr/bin/logger -p daemon.info -i -t rc.php_ini_setup +else + + # Calculate APC SHM size according + # to detected memory values + if [ "$AVAILMEM" -gt "135" ]; then + APCSHMEMSIZE="10M" + fi + if [ "$AVAILMEM" -gt "256" ]; then + APCSHMEMSIZE="20M" + fi + if [ "$AVAILMEM" -gt "384" ]; then + APCSHMEMSIZE="25M" + fi + if [ "$AVAILMEM" -gt "512" ]; then + APCSHMEMSIZE="30M" + fi + if [ "$AVAILMEM" -gt "784" ]; then + APCSHMEMSIZE="50M" + fi fi # Set upload directory @@ -74,7 +88,7 @@ fi # Define php modules. Do not add .so, it will # be done automatically by the script below. PHPMODULES="standard" -if [ "$AVAILMEM" -gt 135 ]; then +if [ "$LOWMEM" != "TRUE" ]; then PHPMODULES="$PHPMODULES apc" fi # Config read/write @@ -249,11 +263,8 @@ for EXT in $PHP_ZEND_MODULES_TS; do fi done -# Get amount of ram installed on this system -RAM=`/sbin/sysctl hw.realmem | /usr/bin/awk '{print $2/1000000}' | /usr/bin/awk -F '.' '{print $1}'` -export RAM -export LOWMEM -if [ "$RAM" -gt 135 ]; then + +if [ "$LOWMEM" != "TRUE" ]; then /bin/cat >>/usr/local/lib/php.ini <>> WARNING! under 128 megabytes of ram detected. Not enabling APC." - echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC." | /usr/bin/logger -p daemon.info -i -t rc.php_ini_setup fi /bin/cat >>/usr/local/lib/php.ini <