123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Install and Configure nginx on Windows</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="Windows,Nginx,Web Server,Self-host,How To,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Install and Configure nginx on Windows">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="05/22/2022 09:37:58 AM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Install and Configure nginx on Windows</h1>
- </div>
- <div></div>
- <div id="content">
- <h2>Installing and Running nginx</h2>
- <ol>
- <li>Download nginx for Windows <a href="http://nginx.org/en/download.html" target="_blank">Download</a></li>
- <li>Extract the downloaded .zip file</li>
- <li>Rename the extracted folder nginx</li>
- <li>Copy the extracted nginx files to the desired location, for example C:\Program Files\nginx</li>
- <li>Open the nginx folder and double click nginx.exe to run the server</li>
- </ol>
- <h2>Adding PHP Support</h2>
- <ol>
- <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>
- <li>Download PHP for Windows (VC15 x64 NTS) <a href="http://windows.php.net/download/" target="_blank">Download</a></li>
- <li>Install Microsoft Visual C++</li>
- <li>Extract the downloaded .zip file</li>
- <li>Rename the extracted folder php</li>
- <li>Copy the extracted php folder to the desired location, for example C:\Program Files\PHP</li>
- <li>Open the php install location and right click in the white space while holding down the Shift key > Open PowerShell window here</li>
- <li>Paste the following command in the PowerShell window to start the PHP CGI process
- <div class="codeBlock">.\php-cgi.exe -b 127.0.0.1:9123</div>
- </li>
- <li>Open Windows Explorer and navigate to the nginx installation directory /conf</li>
- <li>Edit nginx.conf in a text editor</li>
- <li>Add the following lines inside the server object
- <p>location ~ \.php$ {<br />
- fastcgi_pass 127.0.0.1:9123;<br />
- fastcgi_index index.php;<br />
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />
- include fastcgi_params;<br />
- }</p>
- </li>
- <li>Save the changes to nginx.conf</li>
- <li>Right click the Start button > Run > Type taskkill /f /im "nginx.exe" > Press Enter</li>
- <li>Double click nginx.exe to restart the process with PHP support</li>
- </ol>
- <h2>Running nginx Server on Startup</h2>
- <p>nginx doesn'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>
- <ol>
- <li>Open notepad and paste the following into a blank text file<br />
- start "" /b "C:\Program Files\PHP\php-cgi.exe" -b 127.0.0.1:9123<br />
- start "" /b "C:\Program Files\nginx\nginx.exe" -c "C:\Program Files\nginx\conf\nginx.conf"</li>
- <li>Save the text file as startup.bat in the nginx installation directory</li>
- <li>Click the Start button > Search Task > Click Task Scheduler</li>
- <li>Right click the Task Scheduler Library folder in the top left > Create Basic Task</li>
- <li>Name the task nginx startup > Click Next</li>
- <li>Select When the computer starts > Click Next</li>
- <li>Select Start a program > Click Next</li>
- <li>Click the Browse... button and navigate to C:\Program Files\nginx\startup.bat</li>
- <li>Set the Start in value to C:\Program Files\nginx > Click Next</li>
- <li>Click Finish</li>
- <li>Reboot to test that nginx with PHP support starts with the system on boot</li>
- </ol>
- <p>Source: <a href="http://nginx.org/en/docs/windows.html" target="_blank">http://nginx.org/en/docs/windows.html</a></p> </div>
- </div>
- </body>
- </html>
-
|