安装配置 安装kong
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cat > /etc/yum.repos.d/kong.repo <<EOT [kong] baseurl=https://kong.bintray.com/kong-rpm/centos/7 gpgcheck=0 EOT yum install epel-release yum install kong-1.5.1
安装postgresql
安装postgresql
可以从postgresql下载地址 下载安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 yum install https:// download.postgresql.org/pub/ repos/yum/ reporpms/EL-7-x86_64/ pgdg-redhat-repo-latest.noarch.rpm yum install postgresql95 yum install postgresql95-server/usr/ pgsql-9.5 /bin/ postgresql95-setup initdb systemctl enable postgresql-9.5 systemctl start postgresql-9.5
配置 postgresql
和kong
将/var/lib/pgsql/9.5/data/postgresql.conf
中的listen_addresses
注释去掉,并将127.0.0.1
改成*
,同时将port = 5432
注释去掉。
修改 /var/lib/pgsql/9.5/data/pg_hba.conf
中的ident
,将其换成trust
然后重启 systemctl restart postgresql-9.5
新增kong用户
1 2 3 4 5 6 7 8 9 su - postgres << EOF psql << XOFCREATE USER kong; CREATE DATABASE kong OWNER kong; XOF EOF
创建配置文件,cp /etc/kong/kong.conf.default /etc/kong/kong.conf
,并修改/etc/kong/kong.conf
中的内容如下
1 2 3 4 5 6 7 8 database = postgres # Determines which of PostgreSQL or Cassandra # Accepted values are `postgres`, pg_host = 127.0 .0 .1 # Host of the Postgres server . pg_port = 5432 # Port of the Postgres server . pg_timeout = 5000 # Defines the timeout (in ms), for connecting, pg_user = kong # Postgres user . pg_password = 123456 # Postgres user 's password. pg_database = kong # The database name to connect to.
导入kong
的数据, kong migrations bootstrap --v
启动kong
, kong start --conf /etc/kong/kong.conf
检查kong
状态,kong health
验证是否启动成功,
1 2 curl -I -m 10 -o /dev/null -s -w '%{http_code}\n' http:#如果返回的是200,代表启动成功
安装kong
的gui
安装npm 1 2 3 4 5 wget https://nodejs.org/dist/v10.13.0 /node -v10 .13.0 -linux-x64.tar.xz xz -d node -v10 .13.0 -linux-x64.tar.xz tar -xf node -v10 .13.0 -linux-x64.tar ln -s ~/node -v10 .13.0 -linux-x64/bin/node /usr /bin/node ln -s ~/node -v10 .13.0 -linux-x64/bin/npm /usr/bin/npm
配置npm 1 2 3 npm set prefix /usr/localecho -e '\nexport PATH=/usr/local/lib/node_modules:$PATH' >> ~/.bashrcsource ~/.bashrc
安装kong-dashboard
1 npm install -g kong-dashboard
启动kong-dashboard
1 2 3 4 5 6 7 8 kong-dashboard start --kong-url http://localhost :8001 kong-dashboard start --kong-url http://localhost :8001 --port [port] kong-dashboard start --kong-url http://kong :8001 --basic-auth user1=password1 user2=password2
启动的时候可以在后面加上&
,ctr + c
就不会关闭进程了
安装konga
konga 的github地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 npm install -g bowernpm install -g gulpnpm install -g sails git clone https://github.com/pantsel/konga.git cd konganpm inpm run bower-depsnpm install dotenv-extendednpm install angular cp .env_example .env
1 2 3 4 5 6 7 8 9 10 11 cd config/ cp local_example.js local.js vi local.js models: { connection: process.env.DB_ADAPTER || 'localDiskDb' , } # 改成 models: { connection: process.env.DB_ADAPTER || 'postgres' , // 这里可以用‘mysql’,‘mongo’,‘sqlserver’,‘postgres’ }
修改连接信息如下:
1 2 3 4 5 6 7 8 9 10 11 12 postgres: { adapter : 'sails-postgresql', url: process.env .DB_URI , host: process.env .DB_HOST || 'localhost', user: process.env .DB_USER || 'postgres', password: process.env .DB_PASSWORD || null, port: process.env .DB_PORT || 5432, database: process.env .DB_DATABASE ||'konga', // schema: process.env .DB_PG_SCHEMA ||'public', poolSize: process.env .DB_POOLSIZE || 10, ssl: process.env .DB_SSL ? true : false // If set, assume it's true },
1 2 3 4 5 6 7 8 9 10 node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost :5432 /konga npm run production npm install pm2 -g pm2 start app.js --name konga
访问的前提条件是防火墙已经关闭了
1 2 3 4 5 6 7 8 #查看防火墙状态 firewall-cmd --state #停止firewall systemctl stop firewalld.service #禁止firewall开机启动 systemctl disable firewalld.service
pm2相关
1 2 3 4 5 6 7 8 9 10 11 pm2 restart app.js pm2 stop app_name|app_id pm2 stop all pm2 list