The last notes
All English-language materials have been translated fully automatically using the Google service
Having developed the site and prepared the entire infrastructure, I was surprised to find that I could not find a suitable guide (for beginners) for installing strapi on centOS. I'll try to share my experience.
Installing Node..js
Go to the root folder of your project. We will execute all commands from it.
// Go to the project folder
cd / Full_path_to_Your_project /
First of all, we need to get the repository node.js
Latest (January 2020) version:
yum install -y gcc-c ++ make
curl -sL https://rpm.nodesource.com/setup_13.x | sudo -E bash -
Stable version
yum install -y gcc-c ++ make
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
After adding the repository to the system, install node
sudo yum install -y nodejs
To check the node version, use the command:
node -v
To check the npm version:
npm -v
I got an error while installing. The latest version of node was not installed. The distribution kit 6.4.1 was constantly loaded. The problem was in the cache and it was solved quite simply:
// Clearing the cache programmatically
yum clean all
// Physically delete the cache folder
rm -rf / var / cache / yum
Installing strapi
According to the documentation on the developer's site, they recommend yarn
as the installer. Let's use their advice
// Enable yarn repository
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
// Import key from GPG repository
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
Installing yarn
sudo yum install yarn
To check the installation, we can find out the version of yarn:
yarn --version
Install strapi on the system. Why go to the root of the project and type:
// Set strapi
npm install strapi @ alpha -g
The developer documentation clearly states that the alpha version is not recommended on "combat" sites. Either use the stable version, or install at your own risk.
Install sqlite3
npm install sqlite3 --save
Create a strapi project
yarn create strapi-app YOUR_PROJECT_NAME --dev
or
strapi new cms --quickstart
Install admin panel dependencies. Run npm install
from the admin folder. panel ./admin
Start the development server. Run npm start
from the admin folder. panel ./admin
Configuring strapi for publishing to a live server
If everything went well, then in the project console you will be asked to enter the administrator login and password. at http://localhost:1337/admin
This does not suit us, because we are on a production site, which means we will have to tweak the strapi configuration files. We go to the official documentation page and get acquainted with guide . Then go to the production
folder:
cd / config / environments / production
Open the file server.json
, which, by default, looks like this:
{
"host": "localhost",
"port": 1337,
"autoReload": {
"enabled": true
},
"cron": {
"enabled": false
},
"admin": {
"path": "/ dashboard"
}
}
We are interested in the host, port, admin / path
variables. We modify them to your taste. I got it like this:
{
"host": "$ {process.env.APP_HOST || '127.0.0.1' || 'tichiy.ru'}",
"port": "$ {process.env.PORT || 1111}",
"production": true,
"proxy": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false,
"path": "/ dashboard"
}
}
Since the port is used non-standard, the first step is to open it. Go to the file / etc / sysconfig / selinux
and turn off the selinux
setting to get it like this:
SELINUX = disabled
SELINUXTYPE = targeted
Then add a new rule to iptables
iptables -A INPUT -m state --state NEW -p tcp --dport 1111 -j ACCEPT
Or, if it didn't work out through the console, then go to / etc / sysconfig / iptables
and add a new entry manually
-A INPUT -m state --state NEW -p tcp --dport 1111 -j ACCEPT
Restart iptables
systemctl restart iptables
systemctl restart ip6tables
Almost everything is ready. It remains to go to the admin panel and install a new user. Go to http: // Your_domain: 1111 / Admin_panel
and register a new administrator
Comments