diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 084b54b..b82c5b3 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -4,15 +4,15 @@ "fsPath": "$ROOTPATH$/setup.sh", "bookmarks": [ -1, - 17, - 39, + 30, + 42, -1, -1, -1, -1, -1, -1, - 545 + 563 ] } ] diff --git a/etc/nginx/nginx_conf_phphandler.option b/etc/nginx/nginx_conf_phphandler.option deleted file mode 100644 index 7d0c160..0000000 --- a/etc/nginx/nginx_conf_phphandler.option +++ /dev/null @@ -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.*;$ \ No newline at end of file diff --git a/etc/nginx/nginx_conf_phphandler_SOCK.insert b/etc/nginx/nginx_conf_phphandler_SOCK.insert new file mode 100644 index 0000000..5dddf47 --- /dev/null +++ b/etc/nginx/nginx_conf_phphandler_SOCK.insert @@ -0,0 +1,4 @@ + # PHP handler (socket) + upstream php-handler { + server unix:/run/php/php7.2-fpm.sock; + } \ No newline at end of file diff --git a/etc/nginx/nginx_conf_phphandler_TCP.insert b/etc/nginx/nginx_conf_phphandler_TCP.insert new file mode 100644 index 0000000..4006c6a --- /dev/null +++ b/etc/nginx/nginx_conf_phphandler_TCP.insert @@ -0,0 +1,4 @@ + # PHP handler (tcp) + upstream php-handler { + server 127.0.0.1:9000; + } \ No newline at end of file diff --git a/setup.sh b/setup.sh index 7959872..6a88f65 100644 --- a/setup.sh +++ b/setup.sh @@ -51,7 +51,10 @@ tag_cachain="" 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="#$" +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}"