Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function apache_tune {
- # Tunes Apache's memory to use the percentage of RAM you specify, defaulting to 40%
- # $1 - the percent of system memory to allocate towards Apache
- if [ ! -n "$1" ];
- then PERCENT=40
- else PERCENT="$1"
- fi
- aptitude -y install apache2-mpm-prefork
- PERPROCMEM=10 # the amount of memory in MB each apache process is likely to utilize
- MEM=$(grep MemTotal /proc/meminfo | awk '{ print int($2/1024) }') # how much memory in MB this system has
- MAXCLIENTS=$((MEM*PERCENT/100/PERPROCMEM)) # calculate MaxClients
- MAXCLIENTS=${MAXCLIENTS/.*} # cast to an integer
- sed -i -e "s/\(^[ \t]*MaxClients[ \t]*\)[0-9]*/\1$MAXCLIENTS/" /etc/apache2/apache2.conf
- touch /tmp/restart-apache2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement