1、下载 OpenResty
前往官网下载Windows(x64)版本:http://openresty.org/cn/download.html
解压安装后的文件目录(参考)如下:

2、新建临时目录
temp/client_body_temp temp/fastcgi_temp temp/proxy_temp temp/scgi_temp temp/uwsgi_temp
3、新建专门存放 虚拟网站 配置的目录
conf/vhosts
4、配置conf/nginx.conf
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
error_log logs/error.log crit;
#pid logs/nginx.pid;
worker_rlimit_nofile 100000;
events {
worker_connections 40960;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 50m;
client_body_buffer_size 60k;
client_body_timeout 60;
client_header_buffer_size 64k;
client_header_timeout 60;
keepalive_requests 100;
large_client_header_buffers 4 64k;
reset_timedout_connection on;
send_timeout 60;
sendfile_max_chunk 512k;
server_names_hash_bucket_size 256;
# 缓存目录
client_body_temp_path temp/client_body_temp 3 3;
fastcgi_temp_path temp/fastcgi_temp 3 3;
proxy_temp_path temp/proxy_temp 3 3;
scgi_temp_path temp/scgi_temp 3 3;
uwsgi_temp_path temp/uwsgi_temp 3 3;
include vhosts/*.conf;
}
5、新建默认网站,虚拟主机配置:conf/vhosts/0localhost_80.conf
server {
listen 80;
server_name localhost;
root html;
location / {
index index.php index.html;
autoindex off;
}
location ~ \.php(.*)$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass 127.0.0.1:9009;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
6、常用命令行脚本
(1) openresty启动脚本:openresty-start.bat
@echo off
set flag=0
set installPath="D:\wen-jianbao\openresty\openresty-1.19"
set configPath="D:\wen-jianbao\openresty\openresty-1.19"
tasklist|find /i "nginx.exe" > nul
if %errorlevel%==0 (
echo "openresty/nginx already running ! "
exit /b
) else set flag=1
cd /d %installPath%
if %flag%==1 (
start nginx.exe -p %configPath%
ping localhost -n 2 > nul
)
tasklist /fi "imagename eq nginx.exe"
tasklist|find /i "nginx.exe" > nul
if %errorlevel%==0 (
echo "openresty/nginx starting succeced!"
)
(2) openresty停止脚本:openresty-stop.bat
@echo off
tasklist|find /i "nginx.exe" > nul
if %errorlevel%==0 (
taskkill /f /t /im nginx.exe > nul
echo "openresty/nginx stoped!"
) else echo "openresty/nginx not running!"
(3) openresty重启脚本:openresty-restart.bat
@echo off call openresty-stop.bat call openresty-start.bat
(4) openresty状态脚本:openresty-status.bat
@echo off
tasklist|find /i "nginx.exe" > nul
if %errorlevel%==0 (
tasklist /fi "imagename eq nginx.exe"
echo "openresty/nginx is running!"
exit /b
) else echo "openresty/nginx is stoped!"