网站首页 > 博客文章 正文
OpenResty官方安装文档强烈推荐MacOS使用homebrew包管理工具安装 。但是,对于使用老版本Mac系统(如10.13.6)的用户来说不是很友好,安装过程可能会找不到各种依赖、变量等,不如手动编译源码安装OpenResty。
参考Linux下安装OpenResty在Mac上编译安装
安装前准备
安装OpenResty前确保当前机器有以下依赖库:
- perl 5.6.1+
- libreadline
- libpcre
- libssl
参考Linux系统下非root用户安装下安装Nginx安装pcre和openssl即可。
下载源码包、编译、安装
wget https://openresty.org/download/openresty-1.19.3.2.tar.gz
tar xzvf openresty-1.19.3.2.tar.gz # 解压
cd openresty-1.19.3.2/
./configure
make
make install
默认情况下程序会被安装到 /usr/local/openresty 目录。该目录下的nginx目录就是独立的Nginx服务。
配置PATH环境变量
方便操作OpenResty,因为Nginx/OpenResty发布包中并没有提供好的启动、停止脚本,配置完后,就可以在终端直接使用nginx命令了。
vi ~/.zshrc
#添加如下配置
export PATH=/usr/local/openresty/nginx/sbin:$PATH
命令及参数详解
OpenResty 的原始启动命令为 nginx,其参数有-v、-t、-p、-c、-s 等,使用说明如下:
-v参数
表示查看Nginx版本
? ~ nginx -v
nginx version: openresty/1.13.6.2
-c参数
指定一个Nginx配置文件来替换默认的Nginx配置文件
#单独建一个目录,并在目录中创建logs和conf目录
mkdir ~/Software/openresty/work
cd ~/Software/openresty/work
mkdir logs/ conf/
在conf目录下,定义一个后缀为.conf的文件,文件内容如下
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>Hello, World!</p>")
';
}
}
}
启动Nginx:
#若在上一步新建的目录下:
cd ~/Software/openresty/work
#执行下面的命令启动
? work nginx -p ./ -c conf/nginx.conf
#若在其他目录,比如用户目录
? ~ nginx -c ~/Software/openresty/work/conf/nginx.conf
-p参数
表示设置前缀路径
“-p ./”表示将当前目录作为前缀路径,也就是说-c后面指定的配置文件conf/nginx.conf中,所用到的相对路径都加上这个前缀。
"-p ./" 等价于 "-p `pwd`/"
-t参数
表示测试Nginx配置文件语法是否正确
若不能确定编写的Nginx配置文件语法的正确性,就使用-t参数,指定某个配置文件进行检测。不加配置文件路径,默认检测Nginx服务目录下的配置文件。
-s参数
表示给Nginx进程发送信号,包含stop(停止)、reload(重新加载)
? ~ nginx -p ~/Software/openresty/work/ -c conf/nginx.conf -s reload
? ~
? ~ ps -ef|grep nginx
0 1564 1 0 11:09下午 ?? 0:00.00 nginx: master process nginx
-2 1565 1564 0 11:09下午 ?? 0:00.00 nginx: worker process
0 2345 1 0 11:40下午 ?? 0:00.01 nginx: master process nginx -p ./ -c conf/nginx.conf
-2 2833 2345 0 11:51下午 ?? 0:00.00 nginx: worker process
501 2845 495 0 11:51下午 ttys000 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox nginx
? ~
? ~
? ~ nginx -p ~/Software/openresty/work/ -c conf/nginx.conf -s stop
? ~
? ~ ps -ef|grep nginx
0 1564 1 0 11:09下午 ?? 0:00.00 nginx: master process nginx
-2 1565 1564 0 11:09下午 ?? 0:00.00 nginx: worker process
501 2882 495 0 11:52下午 ttys000 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox nginx
? ~
测试
终端下输入curl http://localhost:8080
? ~ curl http://localhost:8080
<p>Hello, World!</p>
? ~
猜你喜欢
- 2024-10-28 SVN 批量add/delete(svn delete commit)
- 2024-10-28 图片和文本差异比较工具:Kaleidoscope Mac版
- 2024-10-28 MAC系统 - 基础知识(苹果macbook 系统)
- 2024-10-28 如何快速实现Git及Mercurial中的版本控制
- 2024-10-28 做产品经理(PM),这些神器就够了(做产品经理需要什么技能)
- 2024-10-28 提升工作效率 Mac 上必备工具(macbookair提升性能)
- 2024-10-28 svn 新增文件不显示,导致无法commit的问题(已解决)
- 2024-10-28 推荐:本人使用频率最高的20款Mac软件(全)
- 2024-10-28 适用于Mac的10个最佳GUI Git客户端
- 2024-10-28 降级MacPorts安装低版本包的妙招(mac降级10.11.6)
你 发表评论:
欢迎- 06-23MySQL合集-mysql5.7及mysql8的一些特性
- 06-23MySQL CREATE TABLE 简单设计模板交流
- 06-23MYSQL表设计规范(mysql设计表注意事项)
- 06-23MySQL数据库入门(四)数据类型简介
- 06-23数据丢失?别慌!MySQL备份恢复攻略
- 06-23MySQL设计规范(mysql 设计)
- 06-23MySQL数据实时增量同步到Elasticsearch
- 06-23MySQL 避坑指南之隐式数据类型转换
- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)