removed phpVersion, detect php socket file from www.conf or leave tag

This commit is contained in:
Asif Bacchus 2019-01-06 05:23:24 -07:00
parent 5e03527996
commit b476a8becf
3 changed files with 20 additions and 34 deletions

View File

@ -4,15 +4,15 @@
"fsPath": "$ROOTPATH$/setup.sh",
"bookmarks": [
-1,
31,
45,
704,
30,
44,
690,
-1,
-1,
-1,
-1,
-1,
179
682
]
}
]

View File

@ -1,4 +1,4 @@
# PHP handler (socket)
upstream php-handler {
server unix:/run/php/php<phpVersion>-fpm.sock;
server unix:<phpSock>;
}

View File

@ -25,7 +25,6 @@ unset CertPath
unset KeyPath
unset CAChainPath
unset DHPath
unset phpVersion
unset phpType
unset noOSCP
@ -59,10 +58,10 @@ file_buffersPHP="nginx/conf.d/buffers_conf_php.insert"
tag_phphandler="#<insert PHP handler.*>$"
file_phphandler="nginx/nginx.conf"
file_phpTCP="nginx/nginx_conf_phphandler_TCP.insert"
file_phpSOCK="nginx/nginx_conf_phphandler_SOCK.insert"
file_phpSock="nginx/nginx_conf_phphandler_SOCK.insert"
tag_phpAddr="<phpAddr>"
tag_phpPort="<phpPort>"
tag_phpVersion="<phpVersion>"
tag_phpSock="<phpSock>"
@ -520,30 +519,6 @@ while true; do
esac
done
# get PHP-FPM version
if [ "${usePHP}" -eq 1 ]; then
while true; do
read -p "What version of PHP-FPM are you using? (default: 7.2) " inputPHPVersion
case $inputPHPVersion in
[[:digit:]]*|+[[:digit:]]*.[[:digit:]]*)
phpVersion="$inputPHPVersion"
break
;;
'')
phpVersion=7.2
break
;;
[Xx]*)
echo -e "\n${cyan}---exiting---\n${norm}"
exit 1
;;
*)
echo -e "\n${err}That does not seem to be a valid version number${norm}"
;;
esac
done
fi
# get PHP-FPM TCP or Sockets configuration
if [ "${usePHP}" -eq 1 ]; then
echo -e "\n${mag}PHP-FPM can be set up to respond to requests via TCP or via UNIX sockets."
@ -619,6 +594,17 @@ if [ "${phpType}" = "tcp" ]; then
done
fi
# get PHP-FPM socket file from www.conf
if [ "${phpType}" = "sockets" ]; then
phpSock=$(find /etc/php/ -name 'www.conf' -type f -exec grep 'listen.*sock$' {} + | sed 's/.*=\ //')
# check if phpSock is null
if [ -z "${phpSock}" ]; then
echo -e "\n${err}Could not auto-detect socket file name${norm}"
echo -e "PHP handler will be set up but you will have to edit ${warn}nginx.conf${norm}"
echo -e "manually to include the proper socket-file name where you see ${warn}<phpSock>${norm}\n"
phpSock='<phpSock>'
fi
fi
### notify user and generate DHParms if necessary
@ -692,9 +678,9 @@ fi
if [ "${phpType}" = "sockets" ]; then
echo -e "updating ${warn}${configPath}/${file_phphandler}${norm}"
# update .insert tag with version number
sed -i "s/${tag_phpVersion}/${phpVersion}/" "${configPath}/${file_phpSOCK}"
sed -i "s/${tag_phpSock}/${phpSock}/" "${configPath}/${file_phpSock}"
# copy .insert file into nginx.conf
sed -i -e "/${tag_phphandler}/{r ${configPath}/${file_phpSOCK}" -e 'd}' "${configPath}/${file_phphandler}"
sed -i -e "/${tag_phphandler}/{r ${configPath}/${file_phpSock}" -e 'd}' "${configPath}/${file_phphandler}"
fi
# notify user file updates are completed