Openresty 解决了什么痛点:OpenResty 究竟解决了什么痛点?
参考方志朋的博客:Openresty最佳案例 | 第3篇:Openresty的安装
centos 开机自动启动openresty: Centos 开机启动Openresty之中的Nginx
官网下载 tar.gz. 包 :http://openresty.org/cn/installation.html
安装或者升级依赖包:
mkdir /usr/local/openresty
mkdir /usr/local/openresty/downloads
cd /usr/local/openresty/downloads
# openresty-1.15.8.3.tar.gz 源码压缩包放到这里
yum install pcre-devel openssl-devel gcc curl
tar -xzvf openresty-VERSION.tar.gz
cd /usr/local/openresty/downloads/openresty-1.15.8.3/bundle/LuaJIT-2.1-20190507
# 编译 安装 LuaJIT
make clean && make && make install
**********安装成功:
# ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit
# ==== Successfully installed LuaJIT 2.1.0-beta3 to /usr/local ====
******************
下载第三方模块:
cd /usr/local/openresty/downloads/openresty-1.15.8.3/bundle
# 下载ngx_cache_purge模块,该模块用于清理nginx缓存
https://github.com/FRiCKLE/ngx_cache_purge/releases
tar -xvf 2.3.tar.gz
# 下载nginx_upstream_check_module模块,该模块用于ustream健康检查
https://github.com/yaoweibin/nginx_upstream_check_module/releases
tar -xvf v0.3.0.tar.gz
1.开始配置
cd /usr/local/openresty/downloads/openresty-1.15.8.3
# 配置帮助
./configure --help
# 配置 启动的模块 和 增加第三方模块
./configure --prefix=/usr/local/openresty --with-luajit --with-http_realip_module
--with-pcre --add-module=./bundle/ngx_cache_purge-2.3
--add-module=./bundle/nginx_upstream_check_module-0.3.0 -j2
当前文件夹里面增加了 build目录
2.gmake
cd /usr/local/openresty/downloads/openresty-1.15.8.3
gmake
3.gmake install
gmake install
安装目录如下:
4.配置Nginx
vim /usr/local/openresty/nginx/conf/nginx.conf
修改如下:
# 添加include lua.conf包含此文件片段
include lua.conf;
# lua模块路径,多个之间”;”分隔,其中”;;”表示默认搜索路径,默认到/usr/local/openresty/lualib下找
lua_package_path "/usr/local/openresty/lualib/?.lua;;"; #lua 模块
lua_package_cpath "/usr/local/openresty/lualib/?.so;;"; #c模块
新建lua.conf文件
vim /usr/local/openresty/nginx/conf/lua.conf
#lua.conf
server {
listen 8083;
server_name _;
location /lua {
default_type 'text/html';
content_by_lua 'ngx.say("hello world")';
}
}
5.设置环境变量
vim /etc/profile
export PATH=$PATH:/usr/local/openresty/nginx/sbin
source /etc/profile
6.测试
# 一般重新启动一个xshell窗口
nginx -t
nginx -s reload
http://192.168.1.7:8083/
http://192.168.1.7:8083/lua
通过访问可以看到欢迎界面,说明安装和配置成功
官方是建议另外建立项目目录,设置配置文件和日志文件
http://openresty.org/cn/getting-started.html
以上的configure ,gmake ,gmake install 过程,重新换一个文件夹(),可以继续走这个流程。旧的安装文件夹直接删除即可。
所以,删除就是直接删除文件夹。