Slime: Installing and Configuring the Nginx Web server under Windows

Source: Internet
Author: User

this article starting at Slime Line the 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

650) this.width=650; "title=" clip_image001 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image001" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432799rh44.png" width= " 858 "height=" 404 "/>

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

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

650) this.width=650; "title=" clip_image002 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image002" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432799BM6C.png" width= " 672 "height=" 349 "/>

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.

650) this.width=650; "title=" clip_image003 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image003" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432800x91U.png" width= " 564 "height=" 370 "/>

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:

650) this.width=650; "title=" clip_image004 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image004" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432800Wavj.png" width= " 825 "height=" 308 "/>

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

650) this.width=650; "title=" clip_image005 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image005" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432800ukVE.png" width= " 908 "height=" 322 "/>

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

650) this.width=650; "title=" clip_image006 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image006" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432801iJQb.png" width= " 667 "height="/>

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:

650) this.width=650; "title=" clip_image007 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image007" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432801wFbC.png" width= " 794 "height=" 569 "/>

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:

650) this.width=650; "title=" clip_image008 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image008" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432801ZQVZ.png" width= " 546 "height=" 222 "/>

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:

650) this.width=650; "title=" clip_image009 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image009" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432802ZVX3.png" width= " 582 "height=" 249 "/>

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>

650) this.width=650; "title=" clip_image010 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image010" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432802Y0qc.png" width= " 493 "height=" 343 "/>

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

Winsw.exe Install

650) this.width=650; "title=" clip_image011 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image011" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432803gcOO.png" width= " "height=" 414 "/>

650) this.width=650; "title=" clip_image012 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image012" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432803YX0n.png" width= " 416 "height=" 438 "/>

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:

650) this.width=650; "title=" clip_image013 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt = "clip_image013" src= "Http://img1.51cto.com/attachment/201410/4/526870_1412432803MOsm.png" width= "597" height= " 598 "/>

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

This article is from the "Slime Row World" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1560638

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.