0177.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Install and Configure nginx on Windows</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Windows,Nginx,Web Server,Self-host,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Install and Configure nginx on Windows">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="05/22/2022 09:37:58 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Install and Configure nginx on Windows</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>Installing and Running nginx</h2>
  26. <ol>
  27. <li>Download nginx for Windows <a href="http://nginx.org/en/download.html" target="_blank">Download</a></li>
  28. <li>Extract the downloaded .zip file</li>
  29. <li>Rename the extracted folder nginx</li>
  30. <li>Copy the extracted nginx files to the desired location, for example C:\Program Files\nginx</li>
  31. <li>Open the nginx folder and double click nginx.exe to run the server</li>
  32. </ol>
  33. <h2>Adding PHP Support</h2>
  34. <ol>
  35. <li><label for="cb_li_410392_0">Download Microsoft Visual C++</label><label for="cb_li_410392_0"><a href="https://aka.ms/vs/16/release/vc_redist.x64.exe" target="_blank">Download</a></label></li>
  36. <li>Download PHP for Windows (VC15 x64 NTS)&nbsp;<a href="http://windows.php.net/download/" target="_blank">Download</a></li>
  37. <li>Install Microsoft Visual C++</li>
  38. <li>Extract the downloaded .zip file</li>
  39. <li>Rename the extracted folder php</li>
  40. <li>Copy the extracted php folder to the desired location, for example C:\Program Files\PHP</li>
  41. <li>Open the php install location and right click in the white space while holding down the Shift key &gt; Open PowerShell window here</li>
  42. <li>Paste the following command in the PowerShell window to start the PHP CGI process
  43. <div class="codeBlock">.\php-cgi.exe -b 127.0.0.1:9123</div>
  44. </li>
  45. <li>Open Windows Explorer and navigate to the nginx installation directory /conf</li>
  46. <li>Edit nginx.conf in a text editor</li>
  47. <li>Add the following lines inside the server object
  48. <p>location ~ \.php$ {<br />
  49. &nbsp; &nbsp; fastcgi_pass &nbsp; 127.0.0.1:9123;<br />
  50. &nbsp; &nbsp; fastcgi_index &nbsp;index.php;<br />
  51. &nbsp; &nbsp; fastcgi_param &nbsp;SCRIPT_FILENAME &nbsp;$document_root$fastcgi_script_name;<br />
  52. &nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_params;<br />
  53. }</p>
  54. </li>
  55. <li>Save the changes to nginx.conf</li>
  56. <li>Right click the Start button &gt; Run &gt; Type taskkill /f /im &quot;nginx.exe&quot; &gt; Press Enter</li>
  57. <li>Double click nginx.exe to restart the process with PHP support</li>
  58. </ol>
  59. <h2>Running nginx Server on Startup</h2>
  60. <p>nginx doesn&#39;t currently have the ability to run as a Windows service natively. A simple workaround is to create a scheduled task to start the nginx server on system startup</p>
  61. <ol>
  62. <li>Open notepad and paste the following into a blank text file<br />
  63. start &quot;&quot; /b &quot;C:\Program Files\PHP\php-cgi.exe&quot; -b 127.0.0.1:9123<br />
  64. start &quot;&quot; /b &quot;C:\Program Files\nginx\nginx.exe&quot; -c &quot;C:\Program Files\nginx\conf\nginx.conf&quot;</li>
  65. <li>Save the text file as startup.bat in the nginx installation directory</li>
  66. <li>Click the Start button &gt; Search Task &gt; Click Task Scheduler</li>
  67. <li>Right click the Task Scheduler Library folder in the top left &gt; Create Basic Task</li>
  68. <li>Name the task nginx startup &gt; Click Next</li>
  69. <li>Select When the computer starts &gt; Click Next</li>
  70. <li>Select Start a program &gt; Click Next</li>
  71. <li>Click the Browse... button and navigate to&nbsp;C:\Program Files\nginx\startup.bat</li>
  72. <li>Set the Start in value to&nbsp;C:\Program Files\nginx &gt; Click Next</li>
  73. <li>Click Finish</li>
  74. <li>Reboot to test that nginx with PHP support starts with the system on boot</li>
  75. </ol>
  76. <p>Source:&nbsp;<a href="http://nginx.org/en/docs/windows.html" target="_blank">http://nginx.org/en/docs/windows.html</a></p> </div>
  77. </div>
  78. </body>
  79. </html>