Installing strapi on bitriVM (CentOS7)
Rus
Eng
Установка strapi на bitriVM (CentOS7)
I solve complex technical challenges for Bitrix and 1C—ranging from auditing existing code to website development and configuring complex integrations—with a guarantee of results.
Recommended

Website hosting

If you are choosing hosting for your project, I recommend Timeweb. Modern infrastructure, a wide range of plans from starter options to high-load VPS, and responsive tech support that actually helps instead of sending template replies. I host some of my own projects there and recommend it to my clients.

Go to site Affiliate link. The price remains the same for you.

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

Aleksandr Tichiy
Author

Aleksandr Tichiy

Fullstack developer · 1C-Bitrix

I build and modernize online stores and corporate portals on 1C-Bitrix. Integrations with 1C, high-load performance, 152-FZ compliance. Writing about architecture and e-commerce.


Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Please message me to discuss the task. I work remotely and officially (as a self-employed professional); my hourly rate is 1,800 RUB, and I can dedicate 3–4 hours a day to the project. I respond quickly, and the consultation is free.

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site