centos6安装openresty

本文详细介绍了在Linux环境下安装和配置OpenResty的过程,包括安装依赖库、下载及解压OpenResty、编译安装、设置环境变量、配置服务启动脚本等步骤,最后验证了安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装依赖库

yum install readline-devel pcre-devel openssl-devel gcc

2、下载openresty

wget --no-check-certificate https://openresty.org/download/openresty-1.11.2.2.tar.gz

3、解压文件

tar xzvf openresty-1.11.2.2.tar.gz

4、进入解压目录,

cd openresty-1.11.2.2

5、安装在/usr/local/openresty目录

./configure --prefix=/usr/local/openresty

6、make

make

7、make install

make install

8、设置环境变量

vi /etc/profile
加下面代码 
PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH
让修改的环境变量生效
source /etc/profile 
9、查看版本
nginx -v

如果出现nginx version: openresty/1.11.2.2,则安装成功

10、设置Nginx为服务和开机启动

vi /etc/rc.d/init.d/nginx

#!/bin/bash
# Tengine Startup script# processname: nginx
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/openresty/nginx/sbin/nginx
nginx_config=/usr/local/openresty/nginx/conf/nginx.conf
nginx_pid=/usr/local/openresty/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "tengine already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;

status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL

11、保存退出

chmod 775 /etc/rc.d/init.d/nginx   #赋予文件执行权限
chkconfig  --level 012345 nginx on   #设置开机启动
service nginx start 

 

转载于:https://www.cnblogs.com/xiaofengfree/p/10261863.html

<think>好的,用户想在CentOS 7上安装OpenResty,我需要根据提供的引用内容整理步骤。首先,引用1和2提到了安装依赖项,包括yum-utils和添加仓库源。然后引用3提到安装OpenResty本身以及resty工具。需要把这些步骤按顺序排列,确保用户能一步步操作。要注意权限问题,可能需要使用sudo或者root权限。另外,安装后的验证步骤也很重要,比如检查版本和启动服务。可能还需要提示用户配置防火墙或者开机启动,但引用里没有提到这些,所以暂时不加入。最后要生成相关问题,覆盖依赖项作用、验证安装、卸载方法以及OpenResty和Nginx的区别,这样用户能有更全面的了解。要确保回答结构清晰,步骤正确,符合用户的需求。</think>以下是CentOS 7安装OpenResty的详细步骤: ### 一、安装依赖项 1. 使用root权限登录服务器 2. 执行以下命令安装基础工具: ```bash yum install -y yum-utils ``` 3. 添加OpenResty官方仓库源: ```bash yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo ```[^1][^2] ### 二、安装OpenResty 1. 通过yum安装主程序包: ```bash yum install -y openresty ```[^3] 2. (可选)安装命令行工具: ```bash yum install -y openresty-resty ```[^3] ### 三、验证安装 1. 查看安装版本: ```bash openresty -v ``` 2. 启动服务: ```bash systemctl start openresty ``` 3. 检查运行状态: ```bash systemctl status openresty ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值