Nginx is running under windows
1. Download nginx
Download the stable version 1.12, here is the download address
http://nginx.org/download/nginx-1.12.2.zip
2, install nginx
Downloaded zip directly decompression, and then double-click nginx.exe, double-click a black pop flashed.
There are local command-line operations after the installation is complete, you need to be in the same directory nginx.exe, the following chart, I was in G: \ under Download \ nginx-1.12.2 directory
3, check whether the installation was successful
In the browser address bar enter the URL http: // localhost: 80, carriage return, appear the following screenshot is installed successfully.
If you visit http: // localhost: 80 when out of iis page,
you need to enter net stop w3svc end of the run iis in cmd inside, and then re-visit http: // localhost: 80
If there are other services take up 80 ports available in the conf directory nginx.conf the port 80 into the inside of the other figures
4, close nginx
Both methods
(1)输入nginx命令 nginx -s stop(快速停止nginx) 或 nginx -s quit(完整有序的停止nginx)
(2)使用taskkill taskkill /f /t /im nginx.exe
5, abnormal reboot
If this abnormal system task manager you can find nginx.exe process, kill it, or find the time to look carefully to find, probably in the following command handler, which may also appear in the background process are killed like
5.1, try to run
5.1.1, shutdown and restart
First check how many nginx is running (you can see in this screenshot only one run)
netstat -an|find "0:80"
If there are multiple, can be closed (the following two commands may be closed)
nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。
nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。
Restart
start nginx
Browser, enter http: // localhost / you the following interface for success
5.1.2, modify the configuration file, try running your own html
在进行这一步之前你可能会遇到其他错误,如果不是因为你修改了某些配置文件造成的,
那可能是因为有多个nginx进程同时在运行,并占用了同一端口,你可以先把它们都杀掉,
然后重新启动,具体参考本文 ‘ 5、重启时出现异常 ’
The configuration file is nginx.conf files in the conf directory
where I put the original nginx.conf a backup, and then modified into the following:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
location / {
root G:/Download/nginx-1.12.2/test;
index index.html index.htm;
}
}
}
G here: /Download/nginx-1.12.2/test I used to test the html directory,
the directory here remember to use / instead of \, otherwise an error
index.html (there must be a name index.htm , remember that if you want to change the index in the back configuration file, directory, and file name into the corresponding)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>我的第一个标题</h1>
<p>我的第一个段落。</p>
</body>
</html>
Browser to access http: // localhost /
Try to run successfully
6, the windows running nginx easy to step pit
- nginx is to adapt to this environment to run linux,
- linux on paths / distinction under a directory,
Windows with \ distinguished under a directory, - So when you run nginx, conf files which have changed with the best path absolute path, and with / to distinguish the next level directory,
as few places should be written as absolute path, or it may be an error (at run time of the test conf probably does not complain, but when you change the path may run conf on the error)
比如这里的
include mime.types;
最好写成 (注意: G:/Download/nginx-1.12.2/conf/ 是我的mime.types所在目录,你应该换成你的mime.types所在目录)
include G:/Download/nginx-1.12.2/conf/mime.types;