通过yum安装Openresty

Openresty官网:http://openresty.org/cn/

1、下载yum-utils

yum install yum-utils -y

2、添加openresty的repo

yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
安装Openresty
yum install openresty -y

安装后,查看一下版本号

resty -V

可以看到默认路径和nginx的路径

默认安装在/usr/local/openresty下

3、添加环境变量
PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH

4、查看
nginx -V

 

 5、编写启动脚本

注意默认路径为:/usr/local/openresty下

如果源码安装时修改了路径,这里的脚本也要修改成对应的路径

vim /etc/init.d/openresty

#!/bin/sh
#
# openresty - this script starts and stops the openresty daemin
#
# chkconfig: - 85 15
# description: OpenResty is a full-fledged web platform that integrates \
# the standard Nginx core, LuaJIT, many carefully written Lua libraries, \
# lots of high quality 3rd-party Nginx modules, and most of their external dependencies.
# processname: openresty
# config: /usr/local/openresty/nginx/conf/nginx.conf
# pidfile: /usr/local/openresty/nginx/logs/nginx.pid
# Last Updated 2018.07.15

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/openresty/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/openresty/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/openresty/nginx/logs/nginx.pid"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
#service php-fpm start
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
$nginx -s stop
echo_success
retval=$?
echo
#service php-fpm stop
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
configtest || return $?
echo -n $"Reloading $prog: "
$nginx -s reload
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac


6、给执行权限
chmod +x /etc/init.d/openresty

7、启动
systemctl start openresty

8、查看状态
systemctl status openresty

9、开机自启
systemctl enable openresty

10、访问openresty

http://localhost

默认是80端口,可以修改端口号在/usr/local/openresty/nginx/conf/nginx.conf修改即可
和修改nginx的配置一样

 

本文作者:小鬼 过来抱~

本文链接:https://www.cnblogs.com/likecoke/p/17576985.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   宝英姐姐  阅读(587)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.