bookmark_borderInstalling Drupal on Alma Linux 8

Hello,
In this week’s feature highlight, we look at How to Install Drupal on Alma Linux 8

Drupal is a Content Management System (CMS) to maintain and publish an internet website. It’s an open-source content management system (CMS) with a large, supportive community. It’s used by millions of people and organizations around the globe to build and maintain their websites.

Update the system.

yum update -y 

Install the MariaDB Server

Install the MariaDB Server by running the following command,

dnf -y install @mariadb

Output:

[root@vps ~]# dnf -y install @mariadb
Last metadata expiration check: 0:11:41 ago on Wednesday 24 November 2021 02:16:41 PM EST.
Dependencies resolved.
===================================================================
 Package                 Arch   Version            Repo       Size
===================================================================
Installing group/module packages:
 mariadb-server          x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                   appstream  16 M
Installing dependencies:
 libaio                  x86_64 0.3.112-1.el8      baseos     33 k
 mariadb                 x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                   appstream 6.0 M
 mariadb-common          x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                   appstream  64 k
 mariadb-connector-c     x86_64 3.1.11-2.el8_3     appstream 200 k
 mariadb-connector-c-config
                         noarch 3.1.11-2.el8_3     appstream  15 k
 mariadb-errmsg          x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                   appstream 234 k

Enable MariaDB using the below command,

systemctl enable --now mariadb

Verify the status of MariaDB using the below command.

systemctl status mariadb 

Output:

[root@vps ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enable>
   Active: active (running) since Wed 2021-11-24 14:30:10 EST; 4s >
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 62687 ExecStartPost=/usr/libexec/mysql-check-upgrade (c>
  Process: 62552 ExecStartPre=/usr/libexec/mysql-prepare-db-dir ma>
  Process: 62528 ExecStartPre=/usr/libexec/mysql-check-socket (cod>
 Main PID: 62656 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 17401)
   Memory: 82.7M
   CGroup: /system.slice/mariadb.service
           └─62656 /usr/libexec/mysqld --basedir=/usr

Secure your database server by setting the root password, disabling root remote logins, and removing test databases.

mysql_secure_installation    

Output:

[root@vps ~]# mysql_secure_installation    

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create Database for Drupal

Create a database for Drupal and grant all privileges to the Drupal user.

mysql -u root -p
CREATE DATABASE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’localhost’ IDENTIFIED BY "StrongPassword";
FLUSH PRIVILEGES;
\q

Output:

[root@vps ~]# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE drupal;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’localhost’ IDENTIFIED BY "strongpassword";
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>     FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>     \q
Bye

Install PHP and Extensions

Install PHP 8.0 as the default version then use the commands below,

dnf module -qy reset  php
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf module install php:remi-8.0 -y
dnf -y install php php-{cli,fpm,gd,mysqlnd,mbstring,json,common,dba,dbg,devel,embedded,enchant,bcmath,gmp,intl,ldap,odbc,pdo,opcache,pear,pgsql,process,snmp,soap,xml,xmlrpc,opcache}

Confirm PHP version,

php -v 

Output:

[root@vps ~]# php -v
PHP 8.0.13 (cli) (built: Nov 16 2021 18:07:21) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Start php-fpm service on your server using the below command,

systemctl enable php-fpm
systemctl start php-fpm

Install Apache Webserver

Install the Apache Webserver by running the following command,

dnf -y install httpd

Output:

[root@vps ~]# dnf -y install httpd
Last metadata expiration check: 0:17:30 ago on Wednesday 24 November 2021 02:16:41 PM EST.
Dependencies resolved.
===================================================================
 Package            Arch   Version                 Repo       Size
===================================================================
Installing:
 httpd              x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1
                                                   appstream 1.4 M
Installing dependencies:
 apr                x86_64 1.6.3-12.el8            appstream 129 k
 apr-util           x86_64 1.6.1-6.el8             appstream 105 k
 almalinux-logos-httpd noarch 85.8-2.el8              baseos     75 k
 httpd-filesystem   noarch 2.4.37-43.module_el8.5.0+1022+b541f3b1
                                                   appstream  39 k
 httpd-tools        x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1
                                                   appstream 107 k

Set PHP Memory limit,

vi /etc/php.ini
memory_limit = 256M

Start PHP and httpd services,

systemctl enable --now httpd php-fpm

If firewalld service running open port for 80,

firewall-cmd --add-service={http,https} --permanent
firewall-cmd --reload

Download and Install Drupal

Download and install Drupal by running the following command,

dnf install -y wget 
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

Extract downloaded file,

dnf install tar
tar xvf drupal.tar.gz
mv drupal-*/  /var/www/html/drupal

Modify the file permissions to allow Apache to access the files inside /var/www/html/drupal directory,

chown -R apache:apache /var/www/html/drupal
chmod -R 755 /var/www/html/

Create additional files for drupal installer,

mkdir /var/www/html/drupal/sites/default/files
cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php

If SELinux is Enabled then Fix selinux lables,

dnf install policycoreutils-python-utils
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'
restorecon -Rv /var/www/html/drupal
restorecon -v /var/www/html/drupal/sites/default/settings.php
restorecon -Rv /var/www/html/drupal/sites/default/files
chown -R apache:apache  /var/www/html/drupal

Configure Apache Web Server for Drupal

Configure Drupal VirtualHost file /etc/httpd/conf.d/drupal.conf

vi /etc/httpd/conf.d/drupal.conf

Copy the below content and save it into the file.

Replace example.com with your actual domain name.

<VirtualHost *:80>
     ServerName mysite.com
     ServerAlias www.example.com
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/drupal/

     <Directory /var/www/html/drupal>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>
</VirtualHost>         

Restart Apache web server,

systemctl restart httpd

Check and Install Drupal on Alma Linux 8 from the browser.

Access the Drupal configuration page by using http://example.com

Replace example.com with your actual domain.

images

Select an installation profile.

images

Set Database Configure for Drupal.

images

Wait for the installation to complete,

images

Configure your site,

images

You’ll get to the Drupal dashboard in a few,

images

Done.

bookmark_borderRefreshed Website Launched

Hello there!

We’ve launched a refreshed version of our website today, The refreshed version of our website incorporates the same ease of access and clean layout but with improvements around the website to improve readability, usage of space and other components such as information cards to incorporate more information about our products.

We hope this refreshed version of the website helps improve your experience when accessing our website.


As always, Stay tuned for more!

bookmark_borderInstalling Ghost on Alma Linux 8

Hello,
In this week’s feature highlight, we look at How to Install Ghost on Alma Linux 8

Ghost is a free and open source blogging platform written in JavaScript and distributed under the MIT License, designed to simplify the process of online publishing for individual bloggers as well as online publications.

We will now begin with the installation, login as root user on the server.

Update the System.

yum update -y

Set your SELinux to permissive mode.

setenforce 0

sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config    

Add EPEL repository.

dnf -y install epel-release

Create a Sudo User

We will install and configure the Ghost packages under this sudo user.

Use adduser command to add a new user to your system.

adduser ghostadmin

Update the password using passwd command,

passwd ghostadmin     

Use usermod command to add the user to the wheel group.

usermod -aG wheel ghostadmin 

On CentOS, members of the wheel group have sudo privileges.

Use su command to switch to the new user account.

su - ghostadmin

We are using ghostadmin as the sudo user. You can have any other name of your choice. Every command executed here after will be under ghostadmin user.

Install Database Server

Install a database server for Ghost CMS. This can either be MySQL or MariaDB database server.

In this example, we will choose MariaDB, it is a popular database server. The installation is simple and requires just a few steps as shown below,

sudo yum install mariadb-server mariadb

Output:

[ghostadmin@vps ~]$ sudo yum install mariadb-server mariadb
Last metadata expiration check: 1:28:38 ago on Tue 22 Oct 2019 03:03:52 PM EDT.
Dependencies resolved.
================================================================================
Package                    Arch   Version                      Repository
                                                                          Size
================================================================================
Installing:
mariadb                    x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed
                                                         AppStream 6.2 M
mariadb-server             x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed
                                                         AppStream  16 M
Installing dependencies:
mariadb-common             x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed                                                                                                                          AppStream  62 k
mariadb-connector-c        x86_64 3.0.7-1.el8                  
AppStream 148 k

Once the installation is complete, enable MariaDB (to start automatically upon system boot), start the MariaDB and verify the status using the commands below.

sudo systemctl enable mariadb

sudo systemctl start mariadb

sudo systemctl status mariadb

Output:

[ghostadmin@vps ~]$ sudo systemctl enable mariadb
[ghostadmin@vps ~]$ sudo systemctl start mariadb
[ghostadmin@vps ~]$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pre>
Active: active (running) since Tue 2019-10-22 16:35:50 EDT; 50s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
    Main PID: 2630 (mysqld)

Finally, you will want to secure your MariaDB installation by issuing the following command.

sudo mysql_secure_installation

Output:

[ghostadmin@vps ~]$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

When installation completed, Create the database for ghost blog.

sudo mysql -u root -p
CREATE USER ghost@localhost IDENTIFIED BY "StrongPassword";
CREATE DATABASE  ghost; 
GRANT ALL ON ghost.* TO ghost@localhost;
FLUSH PRIVILEGES;
QUIT

Replace StrongPassword with a better one.

Install Latest Version of Node.js

sudo curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - 

sudo yum install -y nodejs

Output:

[ghostadmin@vps ~]$ sudo yum install -y nodejs
Node.js Packages for Enterprise Li 968 kB/s | 1.0 MB     00:01    
Last metadata expiration check: 0:00:01 ago on Wednesday 10 November 2021 10:41:59 AM EST.
Dependencies resolved.
===================================================================
 Package            Arch   Version                Repository  Size
===================================================================
Installing:
 nodejs             x86_64 2:16.2.0-1nodesource  nodesource  32 M
Installing dependencies:
 python3-pip        noarch 9.0.3-19.el8           appstream   20 k
 python3-setuptools noarch 39.2.0-6.el8           baseos     163 k
 python36           x86_64 3.6.8-2.module_el8.4.0+790+083e3d81

Install and Configure NGINX

sudo yum install nginx

Output:

[ghostadmin@vps ~]$ sudo yum install nginx
Last metadata expiration check: 0:00:45 ago on Wednesday 10 November 2021 10:41:59 AM EST.
Dependencies resolved.
===================================================================
 Package                     Arch   Version        Repo       Size
===================================================================
Installing:
 nginx                       x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82

Create new directories for your Ghost configuration files inside /etc/nginx/.

sudo mkdir sites-available
sudo mkdir sites-enabled

Create a configuration file for Ghost at /etc/nginx/sites-available/example.com.

Replace example.com with your actual domain name.

server {
listen 80 default_server;
listen [::]:80 default_server;

server_name example.com;
root /var/www/example.com;

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:2368;
}

client_max_body_size 50m;
}

Create a symlink from sites-available to sites-enabled.

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com

Update the http block in your NGINX config /etc/nginx/nginx.conf file by adding an include for the configuration file you just created. a directive for server_names_hash_bucket_size, and comment out the entire server block.

http {
...
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server_names_hash_bucket_size 64;

# server {
#    listen  80 default_server {
#        ...
#    }
#}
...

Open the firewall services for traffic.

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload

Test your NGINX configuration with this command.

sudo nginx -t

Output:

[ghostadmin@vps ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Start the service with the following commands.

sudo systemctl enable nginx
sudo systemctl start nginx

Verify nginx running or not,

sudo systemctl status nginx

Output:

[ghostadmin@vps ~]$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled;>
   Active: active (running) since Wed 2021-11-10 11:03:19 EST; 3s >
  Process: 46741 ExecStart=/usr/sbin/nginx (code=exited, status=0/>
  Process: 46739 ExecStartPre=/usr/sbin/nginx -t (code=exited, sta>
  Process: 46738 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=>
 Main PID: 46743 (nginx)
    Tasks: 2 (limit: 4960)
   Memory: 3.9M
   CGroup: /system.slice/nginx.service
           ├─46743 nginx: master process /usr/sbin/nginx
           └─46744 nginx: worker process

Install Ghost-CLI

Ghost-CLI is a command line interface (CLI) tool that makes installing and updating Ghost easy.

Install Ghost-CLI.

sudo npm install -g ghost-cli@latest

Setting File Permissions

Replace example.com with your actual domain name.

Create the document root directory for ghost.

sudo mkdir -p /var/www/example.com

Change ownership and permission of the /var/www/example.com.

sudo chown ghostadmin:ghostadmin /var/www/example.com
sudo chmod 775 /var/www/example.com

Install Ghost

Enter to the example.com root directory:

cd /var/www/example.com

Ensure that the directory is empty.

Let us now install Ghost on the directory by running the below command,

sudo ghost install

Output:

Answer each question as prompted.

[ghostadmin@vps example.com]$ sudo ghost install
✔ Checking system Node.js version - found v16.2.0
✔ Checking logged in user
✔ Checking current folder permissions
System checks failed with message: 'Linux version is not Ubuntu 16, 18, or 20'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? Yes
System stack check skipped
ℹ Checking system compatibility [skipped]
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v4.22.1
✔ Finishing install process
? Enter your blog URL: http://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
✔ Configuring Ghost
✔ Setting up instance
+ sudo useradd --system --user-group ghost
☱ 
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

? Sudo Password [hidden]
+ sudo chown -R ghost:ghost /var/www/example.com/content
✔ Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
+ sudo mv /tmp/example.com/example.com.conf /etc/nginx/sites-available/example.com.conf
+ sudo ln -sf /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf
+ sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? Yes
? Enter your email (For SSL Certificate) Your_Email@gmail.com
+ sudo mkdir -p /etc/letsencrypt
+ sudo ./acme.sh --install --home /etc/letsencrypt
+ sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --server letsencrypt --domain example.com --webroot /var/www/example.com/system/nginx-root --reloadcmd "nginx -s reload" --accountemail your_email@gmail.com
✖ Setting up SSL
? Do you wish to set up Systemd? Yes
+ sudo mv /tmp/example.com/ghost_example.com.service /lib/systemd/system/example.com.service
+ sudo systemctl daemon-reload
✔ Setting up Systemd
+ sudo systemctl is-active ghost_example.com
? Do you want to start Ghost? Yes
+ sudo systemctl start ghost_example.com
+ sudo systemctl is-enabled ghost_example.com
+ sudo systemctl enable ghost_example.com --quiet
✔ Starting Ghost

view running Ghost processes using below command,

ghost ls

Output:

[ghostadmin@vps example.com]$ ghost ls
+ sudo systemctl is-active ghost_example.com
? Sudo Password [hidden]
┌──────────────────────┬───────────────────────────────┬─────────┬──────────────────────┬─────────────────────────────┬──────┬─────────────────┐
│ Name                 │ Location                      │ Version │ Status               │ URL                         │ Port │ Process Manager │
├──────────────────────┼───────────────────────────────┼─────────┼──────────────────────┼─────────────────────────────┼──────┼─────────────────┤
│ example.com          │ /var/www/example.com          │ 4.22.1  │ running (production) │ http://example.com          │ 2368 │ systemd         │
└──────────────────────┴───────────────────────────────┴─────────┴──────────────────────┴─────────────────────────────┴──────┴─────────────────┘

Once you’ve install Ghost, The first step is to install Certbot for your server. This will allow you to get an SSL certificate to use with Let’s Encrypt.

Install Certbot

As you can notice in the previous step, SSL Certificate failed to generate for the domain. This is because we have the server block configuration in a different directory other than default.

We will now generate the SSL Certificate from Let’s Encrypt manually by running the below commands,

sudo dnf install certbot python3-certbot-nginx

Output:

[ghostadmin@vps example.com]$ sudo dnf install certbot python3-certbot-nginx
Last metadata expiration check: 0:31:02 ago on Wed 10 Nov 2021 10:41:59 AM EST.
Dependencies resolved.
========================================================================================================================================
Package                               Architecture       Version                                           Repository             Size
========================================================================================================================================
Installing:
certbot                               noarch             1.20.0-1.el8                                      epel                   53 k
python3-certbot-nginx                 noarch             1.20.0-1.el8                                      epel                   85 k
Installing dependencies:
python3-acme                          noarch             1.20.0-1.el8                                      epel                   91 k
python3-certbot                       noarch             1.20.0-1.el8                                      epel                  408 k
python3-cffi                          x86_64             1.11.5-5.el8                                      baseos                237 k
python3-chardet                       noarch             3.0.4-7.el8                                       baseos                195 k
python3-configargparse                noarch             0.14.0-6.el8                                      epel                   36 k
python3-cryptography                  x86_64             3.2.1-4.el8                                       baseos                559 k        

Run the following command to generate certificates with the NGINX plug‑in,

sudo certbot --nginx

Access Ghost CMS Dashboard

To complete setup of your publication, visit: http://example.com/ghost

Replace example.com with your actual domain.

Create your first Ghost administrator/publisher account by clicking on “Create your account”.

image
image

Invite other members.

image

You’ll get to Ghost CMS dashboard in a few

image

Done.

bookmark_borderInstalling MongoDB 5 on AlmaLinux 8

Hello,
In this week’s feature highlight, we look at How to Install MongoDB 5 on AlmaLinux 8

MongoDB is a NoSQL database that stores data as JSON-like documents. Documents store related information together and use the MongoDB query language (MQL) for access and it is also called GriddFS which performs load balancing and data replication features over multiple machines for storing files.

Installing MongoDB

Before installing MongoDB, we need to add a repository manually since it is not present in the default repository.

Create a repository file using the following command.

# vi /etc/yum.repos.d/mongodb.repo

And the following line and save the file.

[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

Enter the following command to install MongoDB.

dnf install -y mongodb-org

Next, Start and Enable the MongoDB.

systemctl start mongod

systemctl enable mongod

Command to Verify the MongoDB.

systemctl status mongod

Output:

[root@vps ~]# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enab>
   Active: active (running) since Mon 2021-10-25 13:36:18 EDT; >
     Docs: https://docs.mongodb.org/manual
  Process: 57055 ExecStart=/usr/bin/mongod $OPTIONS (code=exite>
  Process: 57053 ExecStartPre=/usr/bin/chmod 0755 /var/run/mong>
  Process: 57051 ExecStartPre=/usr/bin/chown mongod:mongod /var>
  Process: 57050 ExecStartPre=/usr/bin/mkdir -p /var/run/mongod>
 Main PID: 57058 (mongod)
   Memory: 156.6M
   CGroup: /system.slice/mongod.service
           └─57058 /usr/bin/mongod -f /etc/mongod.conf

MongoDB Shell

Command to access MongoDB’s shell.

mongo

Note: You will receive the following output when you enter the MongoDB shell for the first time.

Output:

[root@vps ~]# mongo
MongoDB shell version v5.0.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("283a2949-15c6-413e-a0f2-6aa95c1bae3a") }
MongoDB server version: 5.0.3
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
We recommend you begin using "mongosh".
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================

Creating MongoDB Admin User

Enter into MongoDB shell.

mongo

Command to switch to the database admin by running.

> use admin

Create an Admin user by running the following code.

Note: Replace a Enter-A-user-Here with a username and Enter-A-Password-Here with a strong and secure password.

> db.createUser(
 {
 user: "Enter-A-user-Here",
 pwd: "Enter-A-Password-Here",
 roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
 }
 )

Output:

 Successfully added user: {
    "user" : "Enter-A-user-Here",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
}
>

Run the following command to list MongoDB users.

> show users

Output:

> show users
{
    "_id" : "admin.Enter-A-user-Here",
    "userId" : UUID("8e2d9f07-e5a0-439c-9893-9fbe1bb33c54"),
    "user" : "Enter-A-user-Here",
    "db" : "admin",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ],
    "mechanisms" : [
        "SCRAM-SHA-1",
        "SCRAM-SHA-256"
    ]
}
> 

Authentication for MongoDB

Note: Since all users can access the shell and execute any commands this will cause security issues — we can prevent this by creating authentication for the admin user.

To enable authentication open the /lib/systemd/system/mongod.service file and find the following line.

Environment="OPTIONS=-f /etc/mongod.conf"

and change to,

Environment="OPTIONS= --auth -f /etc/mongod.conf"

Save and exit the configuration file.

And restart MongoDB to reflect the changes.

systemctl restart mongod

Now you can try to list the user without authentication, you will receive an error

output:

> show users
uncaught exception: Error: command usersInfo requires authentication :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1635:15
shellHelper.show@src/mongo/shell/utils.js:933:9
shellHelper@src/mongo/shell/utils.js:838:15
@(shellhelp2):1:1
> 

To authenticate, simply pass the credentials as shown.

db.auth('mongod_admin', 'YOUR-PASSWORD')

Note: Replace YOUR-PASSWORD with the actual password

Now you can run any command after that. Let’s try listing the users once more:

show users

Output:

{
    "_id" : "admin.Enter-A-user-Here",
    "userId" : UUID("8e2d9f07-e5a0-439c-9893-9fbe1bb33c54"),
    "user" : "Enter-A-user-Here",
    "db" : "admin",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ],
    "mechanisms" : [
        "SCRAM-SHA-1",
        "SCRAM-SHA-256"
    ]
}

To exit the database engine run.

exit    

bookmark_borderInstalling Netdata on Rocky Linux 8

Hello,
In this week’s feature highlight, we look at How to Install Netdata on Rocky Linux 8

Netdata is an Open Source real-time server monitoring tool. It collects real-time data like CPU usage, RAM usage, Load, SWAP usage, Bandwidth usage, Disk usage, etc.

Installing EPEL Repo

Install EPEL Repo by running following command.

dnf install epel-release -y

Output:

[root@server ~]# dnf install epel-release -y
Rocky Linux 8 - AppStream                       959 kB/s | 7.8 MB     00:08
Rocky Linux 8 - BaseOS                          7.6 MB/s | 3.5 MB     00:00
Rocky Linux 8 - Extras                           14 kB/s | 3.8 kB     00:00
Dependencies resolved.
================================================================================
 Package               Architecture    Version            Repository       Size
================================================================================
Installing:
 epel-release          noarch          8-10.el8           extras           22 k

Install required packages for Netdata

Install required packages for Netdata by running following command.

dnf install git libuuid-devel autoconf automake pkgconfig zlib-devel curl findutils libmnl gcc make -y

Clone Netdata from github

Clone Netdata from gituhub by running the following command.

git clone https://github.com/netdata/netdata.git --depth=100

Output:

[root@server ~]# git clone https://github.com/netdata/netdata.git --depth=100
Cloning into 'netdata'...
remote: Enumerating objects: 3073, done.
remote: Counting objects: 100% (3073/3073), done.
remote: Compressing objects: 100% (2286/2286), done.
remote: Total 3073 (delta 1132), reused 1526 (delta 704), pack-reused 0
Receiving objects: 100% (3073/3073), 11.60 MiB | 10.46 MiB/s, done.
Resolving deltas: 100% (1132/1132), done.

Build and Install Netdata

Switch to Netdata directory and install required packages by running the following command.

cd netdata

./packaging/installer/install-required-packages.sh --non-interactive --dont-wait netdata

Run the following command to install libuv-dev.

dnf --enablerepo=powertools install libuv-devel

Run the following script to build and install Netdata.

./netdata-installer.sh

Once the installation is complete, start and enable the Netdata and verify the status using the commands below.

systemctl start netdata

systemctl enable netdata

systemctl status netdata

Output:

[root@server netdata]# systemctl status netdata
● netdata.service - Real time performance monitoring
   Loaded: loaded (/usr/lib/systemd/system/netdata.service; enabled; vendor pre>
   Active: active (running) since Tue 2021-07-06 15:28:44 EDT; 1min 27s ago
 Main PID: 51061 (netdata)
    Tasks: 42 (limit: 11384)
   Memory: 49.5M
   CGroup: /system.slice/netdata.service
           ├─51061 /usr/sbin/netdata -P /var/run/netdata/netdata.pid -D
           ├─51079 /usr/sbin/netdata --special-spawn-server
           ├─51228 /usr/libexec/netdata/plugins.d/ebpf.plugin 1

Firewall Configuration

Netdata listens on port 19999 by default, enable ports in firewall to use Netdata from browser.

firewall-cmd --permanent --add-port=19999/tcp
firewall-cmd --reload

Netdata Dashboard

Enter the following URL on the browser to access the Netdata dashboard. By default netdata works on 19999 port.

http://<Enter Your IP Here>:19999/

The dashboard will look like this.

image