User Tools

Site Tools


servers:windows:nginx_php_php-cgi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
servers:windows:nginx_php_php-cgi [2026/01/17 04:21] – [PHP-CGI] Sean Rhoneservers:windows:nginx_php_php-cgi [2026/02/25 05:51] (current) – [nginx] Sean Rhone
Line 2: Line 2:
  
   * nginx ((https://nginx.org/en/docs/windows.html))   * nginx ((https://nginx.org/en/docs/windows.html))
-  * PHP + PHP-CGI ((https://windows.php.net/download/)) +  * PHP ((https://windows.php.net/download/)) 
-  * [[Information:Realm of Espionage]]+  * PHP-CGI 
 +  * [[information;realm_of_espionage|Realm of Espionage]]
  
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * [[windows;10|Windows 10 (21H2)]]+  * [[windows;10_ltsc_server|Windows 10 (21H2)]]
  
 ====== Install ====== ====== Install ======
Line 13: Line 14:
 ===== nginx ===== ===== nginx =====
  
-  * https://nginx.org/en/download.html +  * https://nginx.org/en/download.html ([[https://nginx.org/en/CHANGES|CHANGES]]) 
-  * Last tested: ''nginx-1.29.4.zip''+  * Last tested: ''nginx-1.29.5.zip''
  
-  * Extract to root system drive for ''C:\nginx-1.29.4\nginx.exe''+  * Extract to root system drive for ''C:\nginx-1.29.5\nginx.exe''
  
   "explorer.exe" "%SystemDrive%"   "explorer.exe" "%SystemDrive%"
  
-  CD "%SystemDrive%\nginx-"*"\" && "nginx.exe" -v+===== PHP-CGI =====
  
-  CD "%SystemDrive%\nginx-"*"\" && "nginx.exe" -t+  * https://windows.php.net/download/ ([[https://windows.php.net/downloads/releases/|raw]]) 
 +  * https://windows.php.net/qa/ ([[https://windows.php.net/downloads/qa/|raw]]) 
 +  * x64 Non Thread Safe 
 +  * Last tested: ''php-8.5.1-nts-Win32-vs17-x64.zip''
  
-==== confs ====+  * Extract to root system drive for ''C:\php-*\php-cgi.exe'' 
 +  * Add to user ''Path''
  
-  MKDIR "%SystemDrive%\www\nginx\conf"+  "explorer.exe" "%SystemDrive%"
  
-  COPY /Y "%SystemDrive%\nginx-1.29.4\conf\fastcgi_params" "%SystemDrive%\www\nginx\conf"+  "SystemPropertiesAdvanced.exe"
  
-  COPY /Y "%SystemDrive%\nginx-1.29.4\conf\mime.types" "%SystemDrive%\www\nginx\conf"+  C:\php-8.5.1-nts-Win32-vs17-x64
  
-==== Firewall ====+====== Firewall ======
  
-  DIR "%SystemDrive%\nginx-1.29.4\nginx.exe"+****
  
-  "netsh.exe" advfirewall firewall add rule name="nginx" dir="in" action="allow" profile="any" program="%SystemDrive%\nginx-1.29.4\nginx.exe" protocol="tcp" localport="80,443"+  CD "%SystemDrive%\nginx-"*"\" && "netsh.exe" advfirewall firewall add rule name="nginx" dir="in" action="allow" profile="any" program="%CD%\nginx.exe" protocol="tcp" localport="80,443"
  
-=== Delete Rule ===+===== Delete Rule =====
  
 **** ****
Line 44: Line 49:
   "netsh.exe" advfirewall firewall delete rule name="nginx"   "netsh.exe" advfirewall firewall delete rule name="nginx"
  
-===== PHP-CGI =====+====== Check Defaults ======
  
-  * https://windows.php.net/download/ +==== nginx ====
-  * https://windows.php.net/qa/ +
-  * x64 Non Thread Safe +
-  * Last tested: ''php-8.5.1-nts-Win32-vs17-x64.zip''+
  
-  Extract to root system drive for ''C:\php-*\php-cgi.exe'' +****
-  Add to user ''Path''+
  
-  "explorer.exe" "%SystemDrive%"+  CD "%SystemDrive%\nginx-"*"\conf" && "notepad.exe" "nginx.conf"
  
-  "SystemPropertiesAdvanced.exe"+==== PHP ====
  
-  C:\php-8.5.1-nts-Win32-vs17-x64+  CD "%SystemDrive%\php-"*"-nts-Win32-"*"-x64\" && "notepad.exe" "php.ini-production" 
 + 
 +  CD "%SystemDrive%\php-"*"-nts-Win32-"*"-x64\" && "notepad.exe" "php.ini-development"
  
 ====== nginx Settings ====== ====== nginx Settings ======
  
-===== Folders =====+===== confs =====
  
-  MKDIR "%SystemDrive%\www\php"+  MKDIR "%SystemDrive%\www\nginx\conf" & CD "%SystemDrive%\nginx-"*"\conf" && COPY /Y "fastcgi_params" "%SystemDrive%\www\nginx\conf\fastcgi_params"
  
-  MKDIR "%SystemDrive%\www\nginx\conf.d"+  MKDIR "%SystemDrive%\www\nginx\conf" & CD "%SystemDrive%\nginx-"*"\conf" && COPY /Y "mime.types" "%SystemDrive%\www\nginx\conf\mime.types"
  
-  MKDIR "%SystemDrive%\www\nginx\default.d"+===== Folders ===== 
 + 
 +****
  
-  MKDIR "%SystemDrive%\www\nginx\vhosts.d"+  MKDIR "%SystemDrive%\www\php" "%SystemDrive%\www\nginx\conf.d" "%SystemDrive%\www\nginx\default.d" "%SystemDrive%\www\nginx\vhosts.d"
  
 ===== HTTPS Redirect ===== ===== HTTPS Redirect =====
Line 80: Line 85:
 <code> <code>
 server { server {
- 
  listen "80" "default_server";  listen "80" "default_server";
  listen "[::]:80" "default_server";  listen "[::]:80" "default_server";
  
  return "301" "https://$host$request_uri";  return "301" "https://$host$request_uri";
- 
 } }
  
Line 92: Line 95:
 ===== Non-existent 404 ===== ===== Non-existent 404 =====
  
-  * This prevents unconfigured subdomains from loading assets from other sites ((if a site/URL doesn'exist, it'll 404))+  * This prevents unconfigured subdomains from loading assets from other sites ((if a site/URL doesn'have a ''vhosts.d\*.conf'', it'll 404))
  
   "notepad.exe" "%SystemDrive%\www\nginx\conf.d\non-existent.conf"   "notepad.exe" "%SystemDrive%\www\nginx\conf.d\non-existent.conf"
Line 98: Line 101:
 <code> <code>
 server { server {
- 
  listen "443" "ssl" "default_server";  listen "443" "ssl" "default_server";
  http2 "on";  http2 "on";
Line 104: Line 106:
  
  return "404";  return "404";
- 
 } }
  
Line 120: Line 121:
 add_header "X-Frame-Options" "sameorigin" "always"; add_header "X-Frame-Options" "sameorigin" "always";
 add_header "X-XSS-Protection" "1; mode=block" "always"; add_header "X-XSS-Protection" "1; mode=block" "always";
-add_header "Cache-Control" "no-store, no-transform, public" "always";+add_header "Cache-Control" "max-age=604800, no-transform, public" "always";
 add_header "Referrer-Policy" "same-origin" "always"; add_header "Referrer-Policy" "same-origin" "always";
 add_header "Expect-CT" "max-age=0" "always"; add_header "Expect-CT" "max-age=0" "always";
Line 163: Line 164:
  
 # End</code> # End</code>
 +
 +  CD "%SystemDrive%\nginx-"*"\" && "nginx.exe" -c "%SystemDrive%\www\nginx\nginx.conf" -t
  
 ==== CSP Headers ==== ==== CSP Headers ====
Line 212: Line 215:
 @echo off @echo off
  
 +TITLE nginx
 CD "%SystemDrive%\nginx-"*"\" CD "%SystemDrive%\nginx-"*"\"
  
Line 227: Line 231:
 @echo off @echo off
  
 +TITLE nginx Stop
 CD "%SystemDrive%\nginx-"*"\" CD "%SystemDrive%\nginx-"*"\"
  
 "nginx.exe" -s "quit" "nginx.exe" -s "quit"
 +
 +TIMEOUT /T "2" /NOBREAK
 +TASKKILL /IM "nginx.exe" /T /F
 +
 +CD "%Temp%"
  
 :: End</code> :: End</code>
Line 246: Line 256:
 "nginx.exe" -s "reload" "nginx.exe" -s "reload"
 "nginx.exe" -s "reopen" "nginx.exe" -s "reopen"
 +
 +CD "%Temp%"
  
 :: End</code> :: End</code>
Line 251: Line 263:
   "%SystemDrive%\www\scripts\nginx\Reload.bat"   "%SystemDrive%\www\scripts\nginx\Reload.bat"
  
-====== Shortcuts ======+====== Task Scheduler ======
  
-===== Autostart ===== +===== nginx =====
- +
-  "explorer.exe" "%AppData%\Microsoft\Windows\Start Menu\Programs\StartUp" +
- +
-  "%SystemDrive%\www\scripts\nginx\Start.bat"+
  
-  nginx+  * Auto-start
  
   SCHTASKS /Create /SC "ONLOGON" /TN "nginx" /TR "%SystemDrive%\www\scripts\nginx\Start.bat" /F   SCHTASKS /Create /SC "ONLOGON" /TN "nginx" /TR "%SystemDrive%\www\scripts\nginx\Start.bat" /F
/usr/local/www/wiki/data/attic/servers/windows/nginx_php_php-cgi.1768641680.txt.gz · Last modified: by Sean Rhone