add PHP-FPM pm.max_children variable option
This commit is contained in:
parent
d6a484f95a
commit
424d6c36fd
|
@ -13,11 +13,12 @@ help()
|
|||
thisfilename=$(basename -- "$0")
|
||||
echo "Add virtualhost to this server."
|
||||
echo ""
|
||||
echo "usage: $thisfilename -d <domain> -u <username> [-h]"
|
||||
echo "usage: $thisfilename -d <domain> -u <username> [-x <fpmmax>] [-h]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -d <domain> Domain name to add as a VirtualHost. www. subdomain is automatically aliased."
|
||||
echo " -u <username> Username to install VirtualHost for. Username must already exist."
|
||||
echo " -x <fpmmax> 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
|
||||
|
|
|
@ -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 <domain> [OPTIONS]"
|
||||
echo "usage: $thisfilename -d <domain> [-u <username>] [-p <password>] [-x <fpmmax>] [-j] [-w] [-h]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -d <domain> Domain name of VirtualHost to remove."
|
||||
echo " -u <username> Username to use for this virtualhost. Optional, defaults to first 8 alphanumeric characters of virtualhost."
|
||||
echo " -p <password> Password for username. Optional, random password generated if none specified."
|
||||
echo " -x <fpmmax> 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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user