安装openresty失败的解决

官网上的安装步骤如下:

tar -xzvf openresty-VERSION.tar.gz
cd openresty-VERSION/
./configure
make
sudo make install

但是我进行到configure这步就报错:

checking for PCRE library ... foundchecking for PCRE JIT support ... foundchecking for OpenSSL library ... not foundchecking for OpenSSL library in /usr/local/ ... not foundchecking for OpenSSL library in /usr/pkg/ ... not foundchecking for OpenSSL library in /opt/local/ ... not found./configure: error: SSL modules require the OpenSSL library.You can either do not enable the modules, or install the OpenSSL libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=<path> option.ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx \...

看来应该把openssl library装好。

具体应该装哪一个呢?看这个文章得知要安装libssl-dev:
http://superuser.com/questions/371901/openssl-missing-during-configure-how-to-fix
如何安装libssl-dev呢?
由于我机器里已经有了libssl1.0.0,所以直接安装libssl-dev时会失败,所以要按如下文章,将其降级后安装。
参考这个文章:http://blog.youkuaiyun.com/andy812110/article/details/24842219
安装成功后,可以继续下一步:make

### 如何将 Nginx 升级到 OpenResty 的教程与最佳实践 要将现有的 Nginx 安装升级至 OpenResty,需遵循一系列操作流程以确保兼容性和功能扩展。以下是详细的说明: #### 1. 下载并安装 OpenResty OpenResty 是基于 Nginx 构建的一个高性能 Web 平台,集成了 LuaJIT 和其他模块。可以通过以下方式下载和安装: ```bash wget https://openresty.org/download/openresty-1.21.4.1.tar.gz tar -xzvf openresty-1.21.4.1.tar.gz cd openresty-1.21.4.1/ ./configure --prefix=/usr/local/openresty \ --with-http_ssl_module \ --with-luajit make && make install ``` 上述命令会完成 OpenResty 的编译和安装[^1]。 #### 2. 替换现有 Nginx 配置文件 在迁移过程中,保留原有的 `nginx.conf` 文件非常重要。将其复制到新的 OpenResty 安装路径下,并调整必要的参数支持 Lua 脚本运行环境。例如,在配置中加入如下内容以便启用 Lua 支持: ```lua location /memleak { content_by_lua_block { ngx.say("Hello, world!") } } ``` 此部分展示了如何通过 Lua 实现动态逻辑处理[^2]。 #### 3. 测试新部署的服务状态 为了确认升级后的服务能够正常运作,建议按照以下方法逐一验证各环节的功能性: - **网页浏览测试**: 打开任意浏览器输入服务器地址查看页面加载情况; - **API 接口调用检测**: 利用 `curl` 工具发送请求检验返回数据准确性; - **日志监控分析**: 查看 `/var/log/nginx/` 中的相关记录排查潜在异常信息。 具体指令如下所示: ```bash curl http://localhost curl -X GET http://localhost/api/test sudo tail -f /var/log/nginx/error.log sudo tail -f /var/log/nginx/access.log ``` #### 4. 处理 WebSocket 连接问题 如果项目涉及实时通信需求,则需要注意设置正确的 HTTP 协议头字段避免握手失败现象的发生。对于 WSS (WebSocket Secure),应确保 NGINX 或 OPENRESTY 正确转发 HTTPS 请求给后端应用层实例。典型解决办法包括但不限于修改站点配置添加类似下面的内容片段: ```nginx map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name localhost; location /ws/ { proxy_pass http://backend_ws_server; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } ``` 以上代码解决了因缺少必要头部而导致连接建立不成功的问题[^4]。 --- ###
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值