diff --git a/bin/vhost-add.sh b/bin/vhost-add.sh index c7c5b22..c507c8c 100755 --- a/bin/vhost-add.sh +++ b/bin/vhost-add.sh @@ -13,11 +13,12 @@ help() thisfilename=$(basename -- "$0") echo "Add virtualhost to this server." echo "" - echo "usage: $thisfilename -d -u [-h]" + echo "usage: $thisfilename -d -u [-x ] [-h]" echo "" echo " -h Print this help." echo " -d Domain name to add as a VirtualHost. www. subdomain is automatically aliased." echo " -u Username to install VirtualHost for. Username must already exist." + echo " -x PHP-FPM pm.max_children. Optional, defaults to 4, recommended range 2-12 on Shared Server." echo " If need be run vhost-user-add.sh first." echo " Or use vhost-deploy.sh instead to automatically generate username." } @@ -36,6 +37,11 @@ if [[ -z $username ]]; then exit fi +# check for php-fpm process manager max children +if [[ -z $fpmmax ]]; then + fpmmax=4 +fi + if [[ ! -d /home/$username ]]; then echo "home dir for $username does not exist" exit 1 @@ -82,7 +88,7 @@ if [[ ! -f /etc/php/$phpVersion/fpm/pool.d/$username.conf ]]; then echo "listen.owner = www-data" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf echo "listen.group = www-data" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf echo "pm = ondemand" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf - echo "pm.max_children = 12" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf + echo "pm.max_children = $fpmmax" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf echo "pm.process_idle_timeout = 3s;" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf echo "php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -fwebmaster@$domain" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf # restart php$phpVersion-fpm diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 8ea283d..43d4884 100755 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -13,12 +13,13 @@ help() thisfilename=$(basename -- "$0") echo "Add virtualhost to this server, including shell user and MySQL database." echo "" - echo "usage: $thisfilename -d [OPTIONS]" + echo "usage: $thisfilename -d [-u ] [-p ] [-x ] [-j] [-w] [-h]" echo "" echo " -h Print this help." echo " -d Domain name of VirtualHost to remove." echo " -u Username to use for this virtualhost. Optional, defaults to first 8 alphanumeric characters of virtualhost." echo " -p Password for username. Optional, random password generated if none specified." + echo " -x PHP-FPM pm.max_children. Optional, defaults to 4, recommended range 2-12 on Shared Server." echo " -j Whether or not to jail the user. Optional, default is to not jail user." echo " -w Write user & mysql info to files. Warning! This inlcudes the unencrypted passwords." exit @@ -107,8 +108,13 @@ if ! grep -q "^$username:" /etc/passwd; then fi fi +# check for php-fpm process manager max children +if [[ -z $fpmmax ]]; then + fpmmax=4 +fi + # add virtualhost -/usr/local/bin/vhost-add.sh -d $domain -u $username > /dev/null 2>&1 +/usr/local/bin/vhost-add.sh -d $domain -u $username -x $fpmmax > /dev/null 2>&1 # add mysql database if [[ -n $write ]]; then diff --git a/bin/vhost.sh b/bin/vhost.sh index e43347c..4c61348 100755 --- a/bin/vhost.sh +++ b/bin/vhost.sh @@ -53,7 +53,7 @@ function vhost::validate_domain () { function vhost:getoptions () { local OPTIND - while getopts "cd:i:m:o:p:u:jhnvw" opt ; do + while getopts "cd:i:m:o:p:u:jhnvwx:" opt ; do case "${opt}" in h ) # display help and exit help @@ -97,6 +97,13 @@ function vhost:getoptions () { w ) # write - store data in file write=true ;; + x ) # php-fpm pm.max_children + fpmmax=${OPTARG} + if [[ $fpmmax != +([[:digit:]]) ]] || [[ $fpmmax -eq 0 ]]; then + echo "ERROR: $fpmax for -x max_children not a valid number." + exit + fi + ;; \? ) echo "Invalid option: $OPTARG" exit 1