subst PHP-handler into nginx.conf

This commit is contained in:
Asif Bacchus 2019-01-05 05:20:11 -07:00
parent f3583f74b2
commit 2468418a64
5 changed files with 27 additions and 25 deletions

View File

@ -4,15 +4,15 @@
"fsPath": "$ROOTPATH$/setup.sh",
"bookmarks": [
-1,
17,
39,
30,
42,
-1,
-1,
-1,
-1,
-1,
-1,
545
563
]
}
]

View File

@ -1,21 +0,0 @@
### This is what the script should insert if PHP is selected
## TCP option -- address and port should be variables, default here
## blank line after closing brace is intentional
# PHP handler (tcp)
upstream php-handler {
server 127.0.0.1:9000;
}
## Socket option -- php version should be variable, default here
## blank line after closing brace is intentional
# PHP handler (socket)
upstream php-handler {
server unix:/run/php/php7.2-fpm.sock;
}
for sed:
append after root.*;$

View File

@ -0,0 +1,4 @@
# PHP handler (socket)
upstream php-handler {
server unix:/run/php/php7.2-fpm.sock;
}

View File

@ -0,0 +1,4 @@
# PHP handler (tcp)
upstream php-handler {
server 127.0.0.1:9000;
}

View File

@ -51,7 +51,10 @@ tag_cachain="<path/to/your_CA_bundle.crt>"
file_mozmodern="nginx/conf.d/mozModern_ssl.conf"
file_buffers="nginx/conf.d/buffers.conf"
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"
### quick intro for the user
echo -e "\n${mag}This script will customize the provided NGINX template files for your"
@ -552,6 +555,18 @@ if [ "${usePHP}" -eq 1 ]; then
cat "${configPath}/${file_buffersPHP}" >> "${configPath}/${file_buffers}"
fi
# if using PHP-TCP: add upstream handler in nginx.conf
if [ "${phpType}" = "tcp" ]; then
echo "updating ${warn}${configPath}/${file_phphandler}${norm}"
sed -i -e "/${tag_phphandler}/{r ${configPath}/${file_phpTCP}" -e 'd}' "${configPath}/${file_phphandler}"
fi
# if using PHP-SOCK: add upstream handler in nginx.conf
if [ "${phpType}" = "sockets" ]; then
echo "updating ${warn}${configPath}/${file_phphandler}${norm}"
sed -i -e "/${tag_phphandler}/{r ${configPath}/${file_phpSOCK}" -e 'd}' "${configPath}/${file_phphandler}"
fi
# debug section
echo -e "\n${mag}---------------------${norm}"