先看下安装文档:
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 .....
完毕!
网友评论