说明
Linux 是Centos7
安装
依次执行下面的命令:
# 安装依赖库:
yum install -y pcre-devel openssl-devel gcc curl
# 下载版本
wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
# 解压
tar -xzvf openresty-1.15.8.1.tar.gz
# 进入解压目录
cd openresty-1.15.8.1/
# 检查配置环境, 生成 Makefile,默认安装到/usr/local/openresty:
./configure
# 编译安装
gmake && gmake install
安装完了显示
gmake[2]: 离开目录“/root/openresty-1.15.8.1/build/nginx-1.15.8”
gmake[1]: 离开目录“/root/openresty-1.15.8.1/build/nginx-1.15.8”
mkdir -p /usr/local/openresty/site/lualib /usr/local/openresty/site/pod /usr/local/openresty/site/manifest
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/bin/openresty
[root@zjj101 openresty-1.15.8.1]#
可以看到openresty 实际上是nginx的软连接。
查看版本号
[root@zjj101 openresty-1.15.8.1]# /usr/local/openresty/bin/openresty -v
nginx version: openresty/1.15.8.1
默认安装位置
安装完了openresty之后Nginx默认的位置是:
/usr/local/openresty/nginx
启动停止
下面的命令根据需求去执行
# 检验配置
/usr/local/openresty/bin/openresty -t
# 启动
/usr/local/openresty/bin/openresty
# 停止
/usr/local/openresty/bin/openresty -s stop
# 重新加载配置
/usr/local/openresty/bin/openresty -s reload
查看进程是否启动
[root@zjj101 openresty-1.15.8.1]# ps -ef|grep openresty
root 106088 1 0 19:07 ? 00:00:00 nginx: master process /usr/local/openresty/bin/openresty
root 106131 96410 0 19:08 pts/0 00:00:00 grep --color=auto openresty
浏览器访问
http://172.16.10.101/
访问完了能在页面看到这些字就说明启动成功了.
Welcome to OpenResty!
If you see this page, the OpenResty web platform is successfully installed and working. Further configuration is required.
For online documentation and support please refer to openresty.org.
Commercial support is available at openresty.com.
Thank you for flying OpenResty.
配置/lib/systemd/system/openresty.service,通过systemctl启动:
vim /lib/systemd/system/openresty.service
[Unit]
Description=openresty - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop
[Install]
WantedBy=multi-user.target
添加openresty.service后,使配置文件生效:
systemctl daemon-reload
然后,就可以使用systemctl管理openresty:
启动
systemctl start openresty
查看启动状态
systemctl status openresty.service
停止
systemctl stop openresty
重载配置
systemctl reload openresty
重启
systemctl restart openresty
参考
https://blog.csdn.net/yisangwu/article/details/106728595