7 C
Texas

How to install Nginx Server on Windows 10

Hello! This time I want to talk to you about Nginx. It is an open-source web server and reverse proxy server. In addition to offering HTTP server capabilities, Nginx can also operate as an IMAP/POP3 mail proxy server as well as function as a load balancer and HTTP cache server. Nginx can run on Linux, Mac OS X, Solaris, AIX, HP-UX, and BSD variants. In comparison to Apache, it is built to offer low memory usage and high concurrency. On the other hand, currently used by more than 30% of web servers. This makes it the second most used web server globally, being used by sites like wordpress.com, mail.ru, huawei.com and many more. For this reason, we are going to see how to install and configure an Nginx web server in Windows 10.

Downloading and Installing Nginx

The first thing we have to do is go to the Nginx website in order to install it. Once there, go to the download section and there select the most recent version. In this case, download version 1.17.3

Download Nginx web server
Download Nginx webserver

The downloaded file is compressed. Next, go to the root of the file system, and there decompress the folder.

C:\nginx-1.17.3\
C:\nginx-1.17.3\

Inside this folder are all the files needed to configure nginx. Before starting the server, it is necessary to edit the configuration file. With this in mind, within the program folder, navigate to the conf folder. Once there, select the file nginx.conf, and open it with the notepad.

Open nginx.conf file
Open nginx.conf file

Editing the nginx.conf file

- Advertisement -

As the name implies, this is the server configuration file. By default, the server loads HTML files. What we will do is allow you to upload images. Besides, we will modify the listening port to avoid conflicts with other services. Please pay attention carefully, because editing the file incorrectly can spoil the functioning of the server. But don’t worry, here I’m going to write textually the lines that you must add or modify. Next, I show you the configuration file as it comes, with marks of where it will be edited.

nginx.conf file open in notepad
nginx.conf file open in notepad

The first thing we are going to do is edit the line corresponding to listen. As you saw in the file, the default port is 80. Change this value and write 8080, to avoid having a conflict with any other service. Then navigate to the line: location / and add the following lines:

location /pictures/ {
     root html;
 }

Check how the file looks once the modifications have been made.

nginx.conf file already edited
nginx.conf file already edited

This will allow the server to load the images you place in that folder. Besides, to make this configuration effective follow this path: C:\nginx-1.17.3\html. Once there, create the pictures folder. Inside the folder place the test image that you want to upload to the server. Remember the name as will be needed later. Then, in the same folder, open the index.html file with notepad.

Open index.html file with notepad
Open index.html file with notepad

immediately below the line Thank you for using nginx, you have to add the following code:

 <img src="/pictures/fuente.jpg" width="500" /> 
index.html file already edited
index.html file already edited

Configuring Windows Firewall

Having modified the listening port, we need to create an input rule to enable connections through port 8080. If you want to know everything about Windows Firewall. And as to create rules of entries and exits, I invite you to check our article on apache in Windows Server

Windows Firewall with an open port to nginx
Windows Firewall with an open port to nginx

Use nginx server

To start the nginx server, please open a Command Prompt by typing cmd in the search bar.

Open a Command Prompt
Open a Command Prompt

Navigate to the server folder, and there type:

 start nginx.exe 
Start nginx web server by CMD
Start nginx web server by CMD

To check that everything is in order, open the web browser of your choice and open the following address: localhost:8080. The welcome page will appear, along with our test image. This means that we have been able to install and configure the server correctly.

nginx welcome page with a test image
nginx welcome page with a test image

To stop the execution of the server just type in the cmd:

 nginx -s stop 

In conclusion, we have learned how to correctly install and configure nginx web server in Windows 10. This powerful alternative to Apáche gives us flexibility when choosing our working server. All right, that’s it for now. Please check our updates on the Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article