Install and Configure nginx on Windows
i12bretro
#nginx #windows #webserver
Full steps can be found at https://i12bretro.github.io/tutorials/0177.html
Installing and Running nginx
- Download nginx for Windows http://nginx.org/en/download.html
- Extract the downloaded .zip file
- Rename the extracted folder nginx
- Copy the extracted nginx files to the desired location, for example C:\Program Files\nginx
- Open the nginx folder and double click nginx.exe to run the server
Adding PHP Support
- Download Microsoft Visual C++ https://aka.ms/vs/16/release/vc_redist.x64.exe
- Download PHP for Windows (VC15 x64 NTS) http://windows.php.net/download/
- Install Microsoft Visual C++
- Extract the downloaded .zip file
- Rename the extracted folder php
- Copy the extracted php folder to the desired location, for example C:\Program Files\PHP
- Open the php install location and right click in the white space while holding down the Shift key ≫ Open PowerShell window here
- Paste the following command in the PowerShell window to start the PHP CGI process .\php-cgi.exe -b 127.0.0.1:9123
- Open Windows Explorer and navigate to the nginx installation directory /conf
- Edit nginx.conf in a text editor
- 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; }
- Save the changes to nginx.conf
- Right click the Start button ≫ Run ≫ Type taskkill /f /im "nginx.exe" ≫ Press Enter
- 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 Files\PHP\php-cgi.exe" -b 127.0.0.1:9123 start "" /b "C:\Program Files\nginx\nginx.exe" -c "C:\Program Files\nginx\conf\nginx.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 Libra ... https://www.youtube.com/watch?v=WDxA0EHEzjI
40891556 Bytes