Install and Configure nginx on Windows
#nginx #windows #webserver
Full steps can be found at https://i12bretro.github.io/tutorials/0177.html
——————————————————————–
Installing and Running nginx
——————————————————————–
01. Download nginx for Windows http://nginx.org/en/download.html
02. Extract the downloaded .zip file
03. Rename the extracted folder nginx
04. Copy the extracted nginx files to the desired location, for example C:Program Filesnginx
05. Open the nginx folder and double click nginx.exe to run the server
——————————————————————–
Adding PHP Support
——————————————————————–
01. Download Microsoft Visual C++ https://aka.ms/vs/16/release/vc_redist.x64.exe
02. Download PHP for Windows (VC15 x64 NTS) http://windows.php.net/download/
03. Install Microsoft Visual C++
04. Extract the downloaded .zip file
05. Rename the extracted folder php
06. Copy the extracted php folder to the desired location, for example C:Program FilesPHP
07. Open the php install location and right click in the white space while holding down the Shift key ≫ Open PowerShell window here
08. Paste the following command in the PowerShell window to start the PHP CGI process
.php-cgi.exe -b 127.0.0.1:9123
09. Open Windows Explorer and navigate to the nginx installation directory /conf
10. Edit nginx.conf in a text editor
11. Add the following lines inside the server object
location ~ .php$ {
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
12. Save the changes to nginx.conf
13. Right click the Start button ≫ Run ≫ Type taskkill /f /im “nginx.exe” ≫ Press Enter
14. Double click nginx.exe to restart the process with PHP support
——————————————————————–
Running nginx Server on Startup
——————————————————————–
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
01. Open notepad and paste the following into a blank text file
start “” /b “C:Program FilesPHPphp-cgi.exe” -b 127.0.0.1:9123
start “” /b “C:Program Filesnginxnginx.exe” -c “C:Program Filesnginxconfnginx.conf”
02. Save the text file as startup.bat in the nginx installation directory
03. Click the Start button ≫ Search Task ≫ Click Task Scheduler
04. Right click the Task Scheduler Library folder in the top left ≫ Create Basic Task
05. Name the task nginx startup ≫ Click Next
06. Select When the computer starts ≫ Click Next
07. Select Start a program ≫ Click Next
08. Click the Browse… button and navigate to C:Program Filesnginxstartup.bat
09. Set the Start in value to C:Program Filesnginx ≫ Click Next
10. Click Finish
11. Reboot to test that nginx with PHP support starts with the system on boot
Source: http://nginx.org/en/docs/windows.html
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro
Comments are closed.