美文网首页
openresty安装和自启动

openresty安装和自启动

作者: 我爱张智容 | 来源:发表于2021-02-12 00:11 被阅读0次

先看下安装文档:

http://openresty.org/en/installation.html

我自己的安装方式:

# 新建用户
userdel www
groupadd www
useradd -g www -M -d /data/www -s /sbin/nologin www &> /dev/null

# 下载解压
wget  xxx.openresty 
tar -zxvf openresty.tar.gz 
cd openresty/ 
./configure --prefix=/opt/openresty && gmake && gmake install  

配置环境变量

# 在结尾增加如下: 
vim /etc/profile  

export OPENRESTY=/opt/openresty
export PATH=$PATH:$OPENRESTY/bin

# 最后生效
source /etc/profile 

配置systemctl 自启动

cat > /lib/systemd/system/openresty.service << EOF
[Unit]
Description=openresty - high performance web server
After=network.target

[Service]
Type=forking
PIDFile=/data/logs/nginx/nginx.pid
ExecStartPost=/bin/sleep 0.1
ExecStartPre=/opt/openresty/nginx/sbin/nginx -t -c /opt/openresty/nginx/conf/nginx.conf
ExecStart=/opt/openresty/nginx/sbin/nginx -c /opt/openresty/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target
<< EOF 

systemctl start openresty.service  //启动nginx
systemctl enable openresty.service  //开机启动 (centos推荐这种方式)

配置第一个虚拟主机

todo .....

完毕!

相关文章

网友评论

      本文标题:openresty安装和自启动

      本文链接:https://www.haomeiwen.com/subject/oqfrxltx.html