Slime: Installing and Configuring the Nginx Web server under Windows

Source: Internet
Author: User

This article by show according to Lin Feng to provide friendship sponsorship, starting in the mud row world.

Previous articles, we use Nginx are all in the Linux environment, today due to the needs of the work. You need to use Nginx to build a Web server in your Windows environment.

Below is recorded under the Nginx construction and configuration.

Note that this experiment uses Windows Server 2003 64bit and is still in the virtual machine. IP address is 192.168.1.221

First go to the official website to download Nginx The latest version of Windows, as follows:

Http://nginx.org/en/download.html

After downloading to the package, unzip the Nginx-1.7.6.zip package to your favorite root directory and change the directory name to Nginx.

Then, under the command line, switch Nginx's home directory to do the following:

CD Nginx

Start Nginx

In this way, the Nginx service is started. Open Task Manager to view the Nginx.exe process, with two processes showing up, consuming system resources, which is fairly small. Such as:

Then open the browser, enter http://127.0.0.1, you can see the Welcome page of Nginx. As follows:

In fact, we can also do the following on the command line nginx:

Nginx–h//View Nginx Help

Nginx-s Stop//Stop Nginx

Nginx-s Reload//Reload configuration file

The next step is to configure the Nginx conf file. The Nginx configuration file under Windows is the same as the Linux configuration file. Here is my configuration:

Worker_processes 1;

PID Logs/nginx.pid;

Events {

Worker_connections 1024;
}

HTTP {

Include Mime.types;
Default_type Application/octet-stream;

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" "$status $body _bytes_sent" $http _referer "'" $http _user_agent "" $http _x_forwarded_for ";

Access_log Logs/access.log Main;

Sendfile on;

Keepalive_timeout 65;

server {

Listen 80;

server_name localhost;

Access_log Logs/host.access.log Main;

Location/{

Root E:\MikroTikRouterOS;

AutoIndex on;

}

}

Now look under the Nginx boot situation that I configured. As follows:

Through, we can obviously see the configuration after the Nginx can still start normally. I have this configuration is the Nginx as an HTTP file server to be there.

The above configuration is supposed to be completed, we can use the normal. But the nginx under Windows is different from the Nginx under Linux, and the Nginx under Linux can start with the system, but the windows are different.

However, in order to enable Nginx to boot with Windows system, we can use "Windows Service Wrapper" This software to implement. But there are a few things we need to do before we do it:

First the Windows system must be installed. NET program. This is to support the Windows Service wrapper software. As follows:

Here we begin to formally configure Windows Service Wrapper:

1, then download the latest version of the Windows Service Wrapper program, such as I download the name is "Winsw-1.9-bin.exe", and then, name it as you want, such as: "Winsw.exe", of course, you can not rename.

2, copy the renamed Winsw.exe file to Nginx's home directory, I am here "E:\nginx".

3. Then create an XML configuration file for Windows Service wrapper in the Nginx home directory, and the name must match the name Winsw.exe used when the first step is renamed, such as "Winsw.xml". As follows:

The contents of the Winsw.xml file are as follows:

<?xml version= "1.0" encoding= "UTF-8"?>

<service>

<id>nginx</id>

<name>nginx</name>

<description>nginx</description>

<executable>E:\nginx\nginx.exe</executable>

<logpath>E:\nginx\</logpath>

<logmode>roll</logmode>

<depend></depend>

<startargument>-p e:\nginx\</startargument>

<stopargument>-p E:\nginx\-S stop</stopargument>

</service>

4. Execute the following command at the command line to install Nginx as a Windows service. As follows:

Winsw.exe Install

Through, we can obviously see that Nginx has been successfully installed into the system's services.

Next, we just need to restart the server to do it. Now under test:

It is clear to see that this time has fully met our requirements.

Add:

The command format for Windows Servcie wrapper is as follows:

# Installation Services

cmd:\> Winsw.exe Install

# Uninstall Service

cmd:\> Winsw.exe Uninstall

# Start Service

Cmd:\> Winsw.exe Start

# Stop Service

Cmd:\> Winsw.exe Stop

Slime: Installing and Configuring the Nginx Web server under Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.