Open Source Selection is a column for us to share high-quality projects in Github, Gitee and other open source communities, including technology, learning, practicality and various interesting content. Recommended in this issue Strapi is a leading open source headless CMS. It is 100% JavaScript, fully customizable and developer first.
Strapi is a free open source headless CMS that can provide your content wherever you need it.
Control your data 。 With Str api, you can know where your data is stored and always maintain full control. self-host 。 You can host and extend the Strapi project in your own way. You can choose any hosting platform you want: AWS, Render, Netlify, Heroku, VPS or dedicated server. You can expand as you grow, 100% independent. Database agnosticism 。 Strapi is applicable to SQL databases. You can select your favorite databases: PostgreSQL, MySQL, MariaDB, and SQLite. Customizable 。 You can quickly build logic by completely customizing APIs, routes, or plug-ins to perfectly meet your needs.
Strapi Features
Modern management panel: elegant, fully customizable and fully extensible management panel. Default security: reusable policy, CORS, CSP, P3P, Xframe, XSS, etc. Plug in oriented: Install the authentication system, content management, and custom plug-ins in seconds. Extremely fast: Strapi is built on Node.js and provides amazing performance. Front end agnosticism: use any front end framework (React, Vue, Angular, etc.), mobile applications, and even the Internet of Things. Powerful CLI: dynamic scaffold project and API. SQL database: applicable to PostgreSQL, MySQL, MariaDB and SQLite.
Install Strapi
Install using Docker
Docker is an open platform that allows the use of containers (that is, packages that contain all the parts required for the application to run, such as libraries and dependencies) to develop, publish, and run applications.
Create an empty folder. In your empty folder, create a docker-compose.yaml file. This is where the new Strapi project is created. It defines the database and Strapi services to be used. version: three
services:
strapi:
image: strapi/strapi
environment:
DATABASE_CLIENT: mysql
DATABASE_HOST: mysql
DATABASE_PORT: three thousand three hundred and six
DATABASE_NAME: strapi
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: strapi
DATABASE_SSL: false
volumes:
- ./app:/srv/app
ports:
- 1337:1337
depends_on:
- mysql
mysql:
image: mysql
command: mysqld --default-authentication-plugin=mysql_native_password
volumes:
- ./data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: strapi
MYSQL_DATABASE: strapi
MYSQL_USER: strapi
MYSQL_PASSWORD: strapi
Use the following command to pull the latest image: docker-compose pull
Run Strapi
To run the Strapi project created with Docker, use one of the following commands:
# Execute Docker image detaching the terminal
docker -compose up -d
# Execute Docker image without detaching the terminal
docker -compose up
DigitalOcean One Button Installation
DigitalOcean is a cloud platform that helps developers deploy and extend applications by providing them with an Infrastructure as a Service (IaaS) platform.
Create a Strapi project
Go to the Strapi page on the DigitalOcean market. Click the Create Strapi Droplet button. Keep the selected Shared CPU - Basic schedule. Select "Regular Intel with SSD" as the CPU option. Select your virtual machine size (at least 2 GB/1 CPU). Select a data center area (closest to you or your target area). Add a new SSH key. You can follow this guide (open a new window) Give your virtual machine a host name. Click Create Droplet. Droplet startup may take 30 seconds to several minutes, while Strapi installation may take several minutes.
Run Strapi
Your Strapi application on DigitalOcean will run in development mode. It is not recommended to use this application directly in production.
To access your Strapi application:
Go to the water drop list on DigitalOcean (open a new window) and log in. Click the name of the droplet used for your Strapi application. Copy the public ipv4 address of the Droplet. Use this address to access the Strapi application.
The first time you access the Strapi application page, you will need to create the first administrator user.
Project Structure
The default structure of the Strapi project created without starting the CLI is as follows:
. # root of the application
├──── .cache # files used to build the admin panel
├──── .tmp
├──── build # build of the admin panel
├──── config # API configurations
│ ├ api.js
│ ├ admin.js
│ ├ cron-tasks.js
│ ├ database.js
│ ├ middlewares.js
│ ├ plugins.js
│ └ server.js
├──── database
│ └──── migrations
├──── node_modules # npm packages used by the project
├──── public # files accessible to the outside world
│ └──── uploads
├──── src
│ ├──── admin # admin customization files
│ ├──── extensions # files to extend the admin panel
│ │ ├ app.js
│ │ └ webpack.config.js
│ ├──── api # business logic of the project split into subfolders per API
│ │ └──── (api- name )
│ │ ├──── content -types
│ │ │ └──── ( content - type - name )
│ │ │ └ lifecycles.js
│ │ │ └ schema.json
│ │ ├──── controllers
│ │ ├──── middlewares
│ │ ├──── policies
│ │ ├──── routes
│ │ ├──── services
│ │ └ index.js
│ ├──── components
│ │ └──── ( category - name )
│ │ ├ (componentA).json
│ │ └ (componentB).json
│ ├──── extensions # files to extend installed plugins
│ │ └──── ( plugin - to -be- extended )
│ │ ├──── content -types
│ │ │ └──── ( content - type - name )
│ │ │ └ schema.json
│ │ └ strapi-server.js
│ ├──── middlewares
│ │ └──── (middleware- name )
│ │ ├ defaults.json
│ │ └ index.js
│ ├──── plugins # local plugins files
│ │ └──── ( plugin - name )
│ │ ├──── admin
│ │ │ └──── src
│ │ │ └ index.js
│ │ ├──── server
│ │ │ ├──── content -types
│ │ │ ├──── controllers
│ │ │ └──── policies
│ │ ├ package.json
│ │ ├ strapi-admin.js
│ │ └ strapi-server.js
│ ├─── policies
│ └ index.js # include register(), bootstrap() and destroy() functions
├ .env
└ package.json
to configure
The application configuration is located in/ Config folder (see Project Structure). All configuration files are loaded at startup and can be accessed through the configuration provider.
If/ The config/server.js file has the following configurations:
module . exports = {
host: 0.0.0.0 ,
};
Server.host can access the key in the following ways:
strapi.config. get ( server.host , defaultValueIfUndefined );
deploy
General guidelines
precondition
For Strapi To provide the best environment, there are some requirements, which are applicable to the development (local), staging and production workflow.
Node LTS(v12 or V14) Please note that the odd version of Node (e.g v13、v15)。
NPM v6 or LTS Anything that comes with the node version
Typical standard building tools for your operating system (most of the build essential tools are based on Debian Software packages on the system)
at least one individual CPU Kernel (highly recommended at least two )
at least two GB Of RAM (medium recommended four )
The minimum storage space recommended by your operating system or thirty-two GB free space
Supported Database Versions
MySQL >= five point seven .8
MariaDB >= ten point two .7
PostgreSQL >= ten
SQLite >= three
Supported Operating Systems
Ubuntu >= eighteen point zero four (Only LTS)
Debian >= nine x
CentOS/RHEL >= eight
macOS Mojave Or later (not supported ARM)
Strapi plug-in
Automatic plug-in discovery
Strapi will automatically load plug-ins installed using npm. In the background, Strapi scans each file of the package.json project dependency and looks for the following statements:
"strapi" : {
"kind" : "plugin"
}
—END—
Open source protocol: MIT License
Open source address:
//github.com/strapi/strapi