内容纲要

下载

https://openresty.org/cn/download.html

[code]
apt-get install libpcre3-dev \
libssl-dev perl make build-essential curl
[/code]

[code]
cd /tmp
wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar -xzvf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2/
./configure
make
sudo make install
[/code]

打开防火墙

[code]
sudo ufw allow http
sudo ufw status
[/code]

启动 OpenResty

[code]
sudo /usr/local/openresty/bin/openresty
[/code]

如果命令成功,它将立即完成而不输出文本。在这种情况下,您可以在浏览器中访问http://your_server_ip 。 你会看到一个页面,说欢迎来到 OpenResty!确认它已完全安装和工作。 您现在可以停止 OpenResty 服务器。

[code]
sudo /usr/local/openresty/bin/openresty -s quit
[/code]

将 OpenResty 设置为服务

[code]
sudo vim /etc/systemd/system/openresty.service
[/code]

[code]
# Stop dance for OpenResty
# A modification of the Nginx systemd script
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the Nginx process.
# If, after 5s (–retry QUIT/5) OpenResty is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if OpenResty is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# Nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=A dynamic web platform based on Nginx and LuaJIT.
After=network.target

[Service]
Type=forking
PIDFile=/run/openresty.pid
ExecStartPre=/usr/local/openresty/bin/openresty -t -q -g ‘daemon on; master_process on;’
ExecStart=/usr/local/openresty/bin/openresty -g ‘daemon on; master_process on;’
ExecReload=/usr/local/openresty/bin/openresty -g ‘daemon on; master_process on;’ -s reload
ExecStop=-/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/openresty.pid
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target
[/code]

[code]
sudo vim /usr/local/openresty/nginx/conf/nginx.conf
[/code]

默认情况下,它将如下所示:

[code]
#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

. . .
[/code]

改为

[code]
user www-data;
worker_processes auto;
pid /run/openresty.pid;

events {
worker_connections 1024;
}

. . .
[/code]

这个文件将确保我们作为 www-data 用户运行,并且systemd可以识别 OpenResty 何时运行,因为 OpenResty 一旦启动就创建了pid行。 保存并关闭文件。 接下来,创建日志目录。

[code]
sudo mkdir /var/log/openresty
[/code]

重新加载systemd服务,以便它可以找到我们的文件。

[code]
sudo systemctl daemon-reload
[/code]

现在,通过systemd启动 OpenResty。

[code]
sudo systemctl start openresty
[/code]

您现在可以再次访问 http://your_server_ip ,并查看与之前相同的网页。 区别是现在,进程已经由systemd 。 最后一步是启用该服务,以确保 OpenResty 在启动时启动。

[code]
sudo systemctl enable openresty
[/code]

其他

https://www.howtoing.com/how-to-use-the-openresty-web-framework-for-nginx-on-ubuntu-16-04

安装 kong

[code]
sudo apt-get install netcat openssl libpcre3 dnsmasq procps perl
[/code]

[code]
sudo apt-get -y install postgresql postgresql-contrib phppgadmin
[/code]

修改 linux 系统 postgres 用户的密码

删除用户 postgres 的密码

[code]
sudo passwd -d postgres
[/code]

设置用户 postgres 的密码

[code]
sudo -u postgres passwd
[/code]

系统提示输入新的密码
[code]
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
[/code]

切换用户
[code]
sudo -i -u postgres
[/code]

[code]
psql
CREATE USER kong; CREATE DATABASE kong OWNER kong;
ALTER USER kong WITH password ‘kong’;
[/code]

[code]
curl -sL https://bintray.com/kong/kong-community-edition-deb/download_file?file_path=dists/kong-community-edition-0.13.0.xenial.all.deb > kong.deb
dpkg -i kong.deb
[/code]

[code]
sudo bash -c "echo -e ‘pg_user = kong\npg_password = kong\npg_database = kong’ > /etc/kong.conf"
kong migrations up
kong start -vv
[/code]

使用 curl,确保 Kong 在运行:
[code]
curl 127.0.0.1:8001
[/code]

– https://github.com/PGBI/kong-dashboard
API gateway 之 kong 基本操作 (三)
– https://github.com/pantsel/konga
kong api 可视化管理工具 konga 安装使用教程

发表评论

电子邮件地址不会被公开。 必填项已用*标注