网站首页 > 博客文章 正文
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)
你 发表评论:
欢迎- 07-08Google Cloud Platform 加入支持 Docker 的容器引擎
- 07-08日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 07-08美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- 07-08GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 07-08谷歌推出Cloud Dataproc,缩短集群启动时间
- 07-08Infovista与Google Cloud携手推进射频网络规划革新
- 07-08比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- 07-08BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- 最近发表
-
- Google Cloud Platform 加入支持 Docker 的容器引擎
- 日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 谷歌推出Cloud Dataproc,缩短集群启动时间
- Infovista与Google Cloud携手推进射频网络规划革新
- 比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- NCSA和Google Cloud合作开发AI驱动的网络防御系统,加强泰国网络空间的安全性
- SAP将在沙特阿拉伯 Google Cloud 上推出BTP服务
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (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)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)