Advertisement
Guest User

Untitled

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