windows openresty 死磕:安装和启动脚本

疯狂创客圈 Java 高并发【 亿级流量聊天室实战】实战系列 【博客园总入口html

架构师成长+面试必备之 高并发基础书籍 【Netty Zookeeper Redis 高并发实战nginx


前言

Crazy-SpringCloud 微服务脚手架 &视频介绍web

Crazy-SpringCloud 微服务脚手架,是为 Java 微服务开发 入门者 准备的 学习和开发脚手架。并配有一系列的使用教程和视频,大体以下:面试

高并发 环境搭建 图文教程和演示视频,陆续上线:windows

中间件 连接地址
Linux Redis 安装(带视频) Linux Redis 安装(带视频)
Linux Zookeeper 安装(带视频) Linux Zookeeper 安装, 带视频
Windows Redis 安装(带视频) Windows Redis 安装(带视频)
RabbitMQ 离线安装(带视频) RabbitMQ 离线安装(带视频)
ElasticSearch 安装, 带视频 ElasticSearch 安装, 带视频
Nacos 安装(带视频) Nacos 安装(带视频)

疯狂创客圈 经典图书 : 《Netty Zookeeper Redis 高并发实战》 面试必备 + 面试必备 + 面试必备浏览器

img

1 windows openresty 的安装

前面提到,OpenResty 的依赖库有: perl 5.6.1+, libreadline, libpcre, libssl。架构

1.1 下载安装 openresty

打开openresty的中文官网,下载网站为:http://openresty.org/cn/download.html 。具体以下图并发

在这里插入图片描述

下载合适的版本, 而后解压便可。微服务

解压到要安装的目录,这里我选择e:/tool目录,你能够根据本身的喜爱选择位置。高并发

使用 openresty-start.bat 启动,而后,在浏览器的地址栏输入 http://localhost:80/,理论上,会有 nginx 的欢迎页面。

可是,也有可能启动失败,以下图:

在浏览器的地址栏输入 localhost,加载 nginx 的欢迎页面。成功加载说明 nginx 正在运行。以下图: 在这里插入图片描述

可能的缘由是,缺乏依赖包。

1.2:须要安装 perl

前面提到,OpenResty 的依赖库有: perl 5.6.1+, libreadline, libpcre, libssl。

首先要安装Perl。 Perl 是 Practical Extraction and Report Language 的缩写,可翻译为 "实用报表提取语言"。Perl 是高级、通用、直译式、动态的程序语言。

若是没有安装perl,启动会报以下错误:

PS E:\tool\openresty-1.15.8.2-win64\conf> resty.bat
'perl' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
You do not have Perl in your PATH.
PS E:\tool\openresty-1.15.8.2-win64\conf>

打开浏览器在搜索栏里面输入: http://strawberryperl.com/ 进入到 perl 官网进行下

在这里插入图片描述

双击打开下载好的 perl安装文件,安装到本身喜欢的目录。这里使用了 e:/tool

使用快捷键 win + r 打开 windows 应用程序, 输入 cmd 来查看是否安装成功

在 cmd 里面输入: perl -version 查看安装版本

PS E:\tool\openresty-1.15.8.2-win64\conf> perl -version

This is perl 5, version 30, subversion 1 (v5.30.1) built for MSWin32-x64-multi-thread

Copyright 1987-2019, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

注意:不能若是安装以前已经打开的cmd窗口,安装以后,须要开启新的cmd窗口

2 windows openresty 的主要命令

考虑到操做方便性,前后建议创建个bat文件,放入系统目录中。

bat文件的脚本以下,已经通过不少次使用。

openresty 启动脚本

openresty 启动: openresty-start.bat

@echo off
set flag=0
set installPath="E:\tool\openresty-1.15.8.2-win64"
set configPath="E:\tool\openresty-1.15.8.2-win64"
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!"
)

主要修改:

1: installPath 为安装目录;

2:configPath为 包含 nignx配置路径 /config 等路径的web工程目录。默认和installPath 相同便可。

openresty 中止脚本

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!"

执行的示例以下:

在这里插入图片描述

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!"

openresty 重启脚本

openresty-restart.bat

@echo off
call openresty-stop.bat
call openresty-start.bat

能够提早从疯狂创客圈的网盘,下载以上的脚本。 在这里插入图片描述

3 正式启动openresty

3.1 脚本修改和启动

前面讲到了 openresty 启动: openresty-start.bat

修改其中的路径,到本身的安装路径,而后启动 在这里插入图片描述

脚本中,使用了 tasklist /fi "imagename eq nginx.exe" 输出了 nginx 进程,其中一个是 master 进程,另外一个是 worker 进程

3.2 查看浏览器界面

在浏览器输入 在浏览器的地址栏输入 http://localhost:80/,能够看到启动成功后的结果:

在这里插入图片描述

具体,请关注 Java 高并发研习社群博客园 总入口


最后,介绍一下疯狂创客圈:疯狂创客圈,一个Java 高并发研习社群博客园 总入口

疯狂创客圈,倾力推出:面试必备 + 面试必备 + 面试必备 的基础原理+实战 书籍 《Netty Zookeeper Redis 高并发实战

img


疯狂创客圈 Java 死磕系列

  • Java (Netty) 聊天程序【 亿级流量】实战 开源项目实战
  • Netty 源码、原理、JAVA NIO 原理

  • Java 面试题 一网打尽

  • 疯狂创客圈 【 博客园 总入口 】 gvMTQ4NTM5OC0yMDE5MDgyMjIyNTE1NjQyNy05NTY0MjQxMjQuanBn?x-oss-process=image/format,png)

相关文章
相关标签/搜索