11<?php 
22// Max Base 
33// https://github.com/BaseMax/NginxWebAutoConfig 
4- <?php 
54// wget https://dl.eff.org/certbot-auto 
65// sudo mv certbot-auto /usr/local/bin/certbot-auto 
76// sudo chown root /usr/local/bin/certbot-auto 
4948foreach ($ domainsas  $ domain
5049	setConfig ($ domain
5150}
51+ function  supportPHP () {
52+ return  "	location ~ \.php \$ {  
53+ 		fastcgi_pass 127.0.0.1:9000; 
54+ 		fastcgi_index index.php; 
55+ 		fastcgi_param SCRIPT_FILENAME  \$document_root \$fastcgi_script_name; 
56+ 		include fastcgi_params; 
57+ 	} 
58+ " ;
59+ }
60+ function  setConfigSub ($ domain$ subdomain
61+ // $config="server { 
62+ // 	#port 
63+ // 	listen 80; 
64+ // 	#domain 
65+ // 	server_name ".$subdomain.".".$domain["name"]."; 
66+ // 	root /site/".$domain["name"]."/sub-".$subdomain."; 
67+ // "; 
68+ // $config.=supportPHP(); 
69+ // $config.="} 
70+ // "; 
71+ // 	file_put_contents("/etc/nginx/conf.d/subdomains/$subdomain.".$domain["name"].".conf", $config); 
72+ }
5273function  setConfig ($ domain
53- 	setConfigSub ($ domain"subdomains " ]);
74+ 	if (isset ($ domain"subdomains " ]) and  is_array ($ domain"subdomains " ]) and  count ($ domain"subdomains " ]) > 0 ) {
75+ 		foreach ($ domain"subdomains " ] as  $ sub
76+ 			setConfigSub ($ domain$ sub
77+ 		}
78+ 	}
5479$ config"server {  
5580	#port 
5681	listen 80; 
@@ -62,6 +87,10 @@ function setConfig($domain) {
6287$ config"	return 301 https:// " .$ domain"name " ]."\$request_uri;  
6388" ;
6489	}
90+ if (isset ($ domain"php " ]) and  $ domain"php " ] == false ) {}
91+ else  if (!isset ($ domain"php " ])) {
92+ $ configsupportPHP ();
93+ }
6594$ config"}  
6695" ;
6796if (isset ($ domain"ssl " ]) and  $ domain"ssl " ] == true ) {
@@ -81,20 +110,20 @@ function setConfig($domain) {
81110server { 
82111	#port 
83112	listen 443 ssl; 
113+ 	#ssl 
114+ 	ssl_certificate /etc/letsencrypt/live/ "$ domain"name " ]."/fullchain.pem;  
115+ 	ssl_certificate_key /etc/letsencrypt/live/ "$ domain"name " ]."/privkey.pem;  
116+ 	include /etc/letsencrypt/options-ssl-nginx.conf; 
117+ 	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
84118	#domain 
85119	server_name  "$ domain"name " ].";  
86120	#config 
87121	root /site/ "$ domain"name " ]."/root;  
88122	index index.htm index.html index.php; 
89123" ;
90- if (!isset ($ domain"name " ] || isset ($ domain"php " ]) and  $ domain"php " ] == false ) {
91- $ config"	location ~ \.php \$ {  
92- 		fastcgi_pass 127.0.0.1:9000; 
93- 		fastcgi_index index.php; 
94- 		fastcgi_param SCRIPT_FILENAME  \$document_root \$fastcgi_script_name; 
95- 		include fastcgi_params; 
96- 	} 
97- " ;
124+ if (isset ($ domain"php " ]) and  $ domain"php " ] == false ) {}
125+ else  if (!isset ($ domain"php " ])) {
126+ $ configsupportPHP ();
98127}
99128if (isset ($ domain"nodejs " ]) and  $ domain"nodejs " ] == false ) {
100129$ config"	location /test/ {  
@@ -107,5 +136,5 @@ function setConfig($domain) {
107136$ config"}  
108137" ;
109138}
110- 	file_put_contents ("/etc/nginx/conf.d/ $ domain.conf " , $ config
139+ 	file_put_contents ("/etc/nginx/conf.d/ "  . $ domain[ " name " ]. " .conf "$ config
111140}
0 commit comments