第一步:Installation
安装地址如下:OpenResty - OpenResty® Linux Packages
点击CentOS跳转到
按照上图中的步骤执行即可安装成功
第二步:Getting Started
2.1:创建脚本:touch start-openresty.sh
2.2:脚本内容如下
#!/bin/bash
#设置OpenResty的安装目录
OPENRESTRY_PATH="/usr/local/openresty"
#设置Nginx项目的工作目录
PROJECT_PATH="/usr/local/openresty/nginx/"
#设置项目的配置文件
#PROJECT_CONF="nginx-location-demo.conf"
PROJECT_CONF="nginx.conf"
echo "OPENRESTRY_PATH:$OPENRESTRY_PATH"
echo "PROJECT_PATH:$PROJECT_PATH"
#查找Nginx所有的进程id
pid=$(ps -ef | grep -v 'grep' | egrep nginx| awk '{printf $2 " "}')
#echo "$pid"
if [ "$pid" != "" ]; then
#如果已经在执行,就提示
echo "openrestry/nginx is started already, and pid is $pid, operating failed!"
else
#如果没有执行,就启动
$OPENRESTRY_PATH/nginx/sbin/nginx -p ${PROJECT_PATH} \
-c ${PROJECT_PATH}/conf/${PROJECT_CONF}
pid=$(ps -ef | grep -v 'grep' | egrep nginx| awk '{printf $2 " "}')
echo "openrestry/nginx starting succeeded!"
echo "pid is $pid"
fi
2.3:执行脚本:sh start-openresty.sh