strapi 是一个开源的内容管理平台,功能操作起来还是比较方便简单的,提供一系列的api,方便用来做一些小程序接口或者应用程序的数据保存接口。
软件版本最低要求
Node.js 12.x , npm 6.x
数据库要求:SQLite 3,PostgreSQL 10,MySQL 5.6,MariaDB 10.1,MongoDB 3.6
如果数据量不大,直接用SQLite,不需要安装其他数据库
1.首先安装nodejs v15 和yarn.
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
yum -y install nodejs
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn
2.启动一个strapi项目
创建项目
yarn create strapi-app my-project --quickstart
进入 my-project 目录,安装mysql依赖
npm install mysql --save
修改配置文件
strapi/config/database.js
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
"client": "mysql",
"database": "test",
"host": "localhost",
"port": "3306",
"username": "test",
"password": "test"
},
options: {
useNullAsDefault: true,
},
},
},
})
启动项目
yarn develop