Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 6f75be6

Browse files
committed
NGINX for local preview on windows
1 parent bd060f9 commit 6f75be6

File tree

10 files changed

+218
-0
lines changed

10 files changed

+218
-0
lines changed

_ngingx/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
logs/*.log
2+
logs/nginx.pid

_ngingx/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Using nginx on Windows
2+
3+
## Preparation
4+
5+
1. Install nginx
6+
* Download nginx/Windows-1.5.13 (or above) from http://nginx.org/en/download.html
7+
* Unzip a downloaded file.
8+
* Place the directory (nginx-1.5.13 or so) where you want.
9+
2. Setup environment value `NGINX_HOME` to point nginx install directory.
10+
11+
## Usage
12+
13+
To start nginx, double click start.cmd
14+
15+
To stop nginx, double click stop.cmd
16+
17+
When you have updated redirect configuration, double click reload.cmd to make
18+
nginx reload it.
19+
20+
## Trouble shooting
21+
22+
* If you can't start nginx server, kill all nginx.exe processes by Windows
23+
TaskManager, then remove logs/nginx.pid file.

_ngingx/cmd/setup.cmd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@ECHO OFF
2+
3+
IF DEFINED NGINX_HOME GOTO HAS_NGINX_HOME
4+
ECHO ERROR: Please define NGINX_HOME environment value.
5+
EXIT /B 1
6+
7+
:HAS_NGINX_HOME
8+
9+
IF EXIST %NGINX_HOME%\nginx.exe GOTO HAS_NGINX_EXE
10+
ECHO ERROR: Please install nginx.exe into %NGINX_HOME%
11+
EXIT /B 1
12+
13+
:HAS_NGINX_EXE
14+
EXIT /B 0

_ngingx/conf/mime.types

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
types {
3+
text/html html htm shtml;
4+
text/css css;
5+
text/xml xml;
6+
image/gif gif;
7+
image/jpeg jpeg jpg;
8+
application/javascript js;
9+
application/atom+xml atom;
10+
application/rss+xml rss;
11+
12+
text/mathml mml;
13+
text/plain txt;
14+
text/vnd.sun.j2me.app-descriptor jad;
15+
text/vnd.wap.wml wml;
16+
text/x-component htc;
17+
18+
image/png png;
19+
image/tiff tif tiff;
20+
image/vnd.wap.wbmp wbmp;
21+
image/x-icon ico;
22+
image/x-jng jng;
23+
image/x-ms-bmp bmp;
24+
image/svg+xml svg svgz;
25+
image/webp webp;
26+
27+
application/font-woff woff;
28+
application/java-archive jar war ear;
29+
application/json json;
30+
application/mac-binhex40 hqx;
31+
application/msword doc;
32+
application/pdf pdf;
33+
application/postscript ps eps ai;
34+
application/rtf rtf;
35+
application/vnd.apple.mpegurl m3u8;
36+
application/vnd.ms-excel xls;
37+
application/vnd.ms-fontobject eot;
38+
application/vnd.ms-powerpoint ppt;
39+
application/vnd.wap.wmlc wmlc;
40+
application/vnd.google-earth.kml+xml kml;
41+
application/vnd.google-earth.kmz kmz;
42+
application/x-7z-compressed 7z;
43+
application/x-cocoa cco;
44+
application/x-java-archive-diff jardiff;
45+
application/x-java-jnlp-file jnlp;
46+
application/x-makeself run;
47+
application/x-perl pl pm;
48+
application/x-pilot prc pdb;
49+
application/x-rar-compressed rar;
50+
application/x-redhat-package-manager rpm;
51+
application/x-sea sea;
52+
application/x-shockwave-flash swf;
53+
application/x-stuffit sit;
54+
application/x-tcl tcl tk;
55+
application/x-x509-ca-cert der pem crt;
56+
application/x-xpinstall xpi;
57+
application/xhtml+xml xhtml;
58+
application/xspf+xml xspf;
59+
application/zip zip;
60+
61+
application/octet-stream bin exe dll;
62+
application/octet-stream deb;
63+
application/octet-stream dmg;
64+
application/octet-stream iso img;
65+
application/octet-stream msi msp msm;
66+
67+
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
68+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
69+
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
70+
71+
audio/midi mid midi kar;
72+
audio/mpeg mp3;
73+
audio/ogg ogg;
74+
audio/x-m4a m4a;
75+
audio/x-realaudio ra;
76+
77+
video/3gpp 3gpp 3gp;
78+
video/mp2t ts;
79+
video/mp4 mp4;
80+
video/mpeg mpeg mpg;
81+
video/quicktime mov;
82+
video/webm webm;
83+
video/x-flv flv;
84+
video/x-m4v m4v;
85+
video/x-mng mng;
86+
video/x-ms-asf asx asf;
87+
video/x-ms-wmv wmv;
88+
video/x-msvideo avi;
89+
}

_ngingx/conf/nginx.conf

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
worker_processes 1;
2+
3+
events {
4+
worker_connections 1024;
5+
}
6+
7+
http {
8+
include mime.types;
9+
default_type application/octet-stream;
10+
11+
sendfile on;
12+
13+
keepalive_timeout 65;
14+
15+
server {
16+
listen 4000;
17+
server_name localhost;
18+
19+
location / {
20+
root ../_site/;
21+
index index.html index.htm;
22+
}
23+
24+
#error_page 404 /404.html;
25+
26+
# redirect server error pages to the static page /50x.html
27+
#
28+
error_page 500 502 503 504 /50x.html;
29+
location = /50x.html {
30+
root html;
31+
}
32+
33+
#include ../../_site/nginx-redirect.conf;
34+
}
35+
}

_ngingx/logs/.gitkeep

Whitespace-only changes.

_ngingx/reload.cmd

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@ECHO OFF
2+
3+
CD %~dp0
4+
5+
CALL cmd\setup.cmd
6+
IF ERRORLEVEL 1 GOTO ERROR_END
7+
8+
IF EXIST logs/nginx.pid GOTO RUNNING_NGINX
9+
ECHO NGINX is not running yet.
10+
GOTO ERROR_END
11+
12+
:RUNNING_NGINX
13+
%NGINX_HOME%\nginx -c conf/nginx.conf -s reload
14+
15+
GOTO END
16+
:ERROR_END
17+
PAUSE
18+
:END

_ngingx/start.cmd

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@ECHO OFF
2+
3+
CD %~dp0
4+
5+
CALL cmd\setup.cmd
6+
IF ERRORLEVEL 1 GOTO ERROR_END
7+
8+
IF NOT EXIST logs/nginx.pid GOTO NO_RUNNING_NGINX
9+
ECHO NGINX is running already.
10+
GOTO :ERROR_END
11+
12+
:NO_RUNNING_NGINX
13+
ECHO NGINX Listening http://127.0.0.1:4000/
14+
%NGINX_HOME%\nginx -c conf/nginx.conf
15+
16+
GOTO END
17+
:ERROR_END
18+
PAUSE
19+
:END

_ngingx/stop.cmd

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@ECHO OFF
2+
3+
CD %~dp0
4+
5+
CALL cmd\setup.cmd
6+
IF ERRORLEVEL 1 GOTO ERROR_END
7+
8+
IF EXIST logs/nginx.pid GOTO RUNNING_NGINX
9+
ECHO NGINX is not running yet.
10+
GOTO ERROR_END
11+
12+
:RUNNING_NGINX
13+
%NGINX_HOME%\nginx -c conf/nginx.conf -s stop
14+
15+
GOTO END
16+
:ERROR_END
17+
PAUSE
18+
:END

_ngingx/temp/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)