diff --git a/bin/vhost-add.sh b/bin/vhost-add.sh index 9e2cbcb..398f061 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 [-f ] [-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 " -f PHP-FPM version to enable. Optional, defaults to default PHP version." echo " If need be run vhost-user-add.sh first." echo " Or use vhost-deploy.sh instead to automatically generate username." } @@ -36,6 +37,12 @@ if [[ -z $username ]]; then exit fi +# set php-fpm to default php version, if not otherwise specified +if [[ -z $fpm ]]; then + vhost::set-phpVersion + fpm=$phpVersion +fi + if [[ ! -d /home/$username ]]; then echo "home dir for $username does not exist" exit 1 @@ -65,17 +72,14 @@ if [[ -d /usr/jails/$username ]]; then install -d -o $username -g $username -m 755 /usr/jails/$username/srv/www/$domain mount --bind /srv/www/$domain /usr/jails/$username/srv/www/$domain echo "/srv/www/$domain /usr/jails/$username/srv/www/$domain none bind 0 0" >> /etc/fstab.jails + # ensure php-fpm is chrooted. should have already been set when user was initially jailed + if [[ -f /etc/php/$fpm/fpm/pool.d/$username.conf ]]; then + if ! /bin/grep -q "^chroot" /etc/php/$fpm/fpm/pool.d/$username.conf; then + echo "chroot = /usr/jails/$username" >> /etc/php/$fpm/fpm/pool.d/$username.conf + fi + fi fi fi -# set sendmail_path in php-fpm, but only if not already set -## disabled, now relying on defaults (user@fqdn) with .forward (/home/user/.forward) -## vhost::set-phpVersion -## if [[ -f /etc/php/$phpVersion/fpm/pool.d/$username.conf ]]; then -## if ! /bin/grep -q "^php_admin_value\[sendmail_path\]" /etc/php/$phpVersion/fpm/pool.d/$username.conf; then -## echo "php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -fwebmaster@$domain" >> /etc/php/$phpVersion/fpm/pool.d/$username.conf -## fi -## fi - # create & enable apache config -/usr/local/bin/vhost-enable.sh -d $domain -m VHostHTTP +/usr/local/bin/vhost-enable.sh -d $domain -m VHostHTTP -f $fpm diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 370af3d..052bbe4 100755 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -13,13 +13,14 @@ help() thisfilename=$(basename -- "$0") echo "Add virtualhost to this server, including shell user and MySQL database." echo "" - echo "usage: $thisfilename -d [-u ] [-p ] [-x ] [-j <0|1>] [-w <0|1>] [-h]" + echo "usage: $thisfilename -d [-u ] [-p ] [-x ] [-f ] [-j <0|1>] [-w <0|1>] [-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 " -f PHP-FPM version to enable. Optional, defaults to default PHP version." echo " -j <0|1> Whether or not to jail the user. 0 = no, 1 = yes. Default is 1, which can be overridden in main config." echo " -w <0|1> Write user info to /home/username/.passwd. 0 = no, 1 = yes. Default is 1, which can be overridden in main config." exit @@ -117,8 +118,14 @@ if ! grep -q "^$username:" /etc/passwd; then fi fi +# set php-fpm to default php version, if not otherwise specified +if [[ -z $fpm ]]; then + vhost::set-phpVersion + fpm=$phpVersion +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 -f $fpm > /dev/null 2>&1 # add mysql database /usr/local/bin/vhost-mysql-db-add.sh -d $domain> /dev/null 2>&1 diff --git a/bin/vhost-enable.sh b/bin/vhost-enable.sh index d908f4d..882a903 100755 --- a/bin/vhost-enable.sh +++ b/bin/vhost-enable.sh @@ -13,11 +13,12 @@ help() thisfilename=$(basename -- "$0") echo "Enable Apache config for virtualhost." echo "" - echo "usage: $thisfilename -d [-m ] [-o |] [-h]" + echo "usage: $thisfilename -d [-m ] [-f ] [-o |] [-h]" echo "" echo " -h Print this help." echo " -d Domain name of VirtualHost to add." echo " -m Name of Apache macro to apply. Optional, script will attempt to autoselect if possible." + echo " -f PHP-FPM version to enable. Optional, defaults to default PHP version, only used by VHost macros." echo " -o