bookmark_borderHow to Install Gitlab on Ubuntu 22 04

Hello,

In this week’s feature highlight, we look at How to Install Gitlab on Ubuntu 22 04

GitLab is a web-based DevOps lifecycle tool that provides a Git repository manager providing wiki, issue-tracking, and continuous integration and deployment pipeline features, using an open-source license, developed by GitLab Inc.

Update System

First, update your existing list of packages

apt update

apt upgrade -y

Install required dependencies

apt-get install -y curl openssh-server ca-certificates

Add the GitLab Repository

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

Install Gitlab

Download the Gitlab package using the following command

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.2-ce.0_amd64.deb/download.deb 

Output:

 root@crown:~# wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.2-ce.0_amd64.deb/download.deb
--2022-03-16 20:29:49--  https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.2-ce.0_amd64.deb/download.deb
Resolving packages.gitlab.com (packages.gitlab.com)... 104.18.27.123, 104.18.26.123, 2606:4700::6812:1a7b, ...
Connecting to packages.gitlab.com (packages.gitlab.com)|104.18.27.123|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://d20rj4el6vkp4c.cloudfront.net/7/8/ubuntu/package_files/110770.deb?t=1647462889_dfa2d924370e258ffb8d48079c1fd435029de6b7 [following]
--2022-03-16 20:29:49--  https://d20rj4el6vkp4c.cloudfront.net/7/8/ubuntu/package_files/110770.deb?t=1647462889_dfa2d924370e258ffb8d48079c1fd435029de6b7

Install the downloaded .deb the package on Ubuntu 22.04 using the below command

dpkg -i gitlab-ce_14.1.2-ce.0_amd64.deb

Output:

root@crown:~#dpkg -i gitlab-ce_14.1.2-ce.0_amd64.deb 
Selecting previously unselected package gitlab-ce.
(Reading database ... 73374 files and directories currently installed.)
Preparing to unpack gitlab-ce_14.1.2-ce.0_amd64.deb ...
Unpacking gitlab-ce (14.1.2-ce.0) ...
Setting up gitlab-ce (14.1.2-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.

Reconfigure GitLab services using the below command

gitlab-ctl reconfigure

Output:

root@crown:~#gitlab-ctl reconfigure
Starting Chef Infra Client, version 15.14.0
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - logrotate (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - monitoring (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - consul (0.1.0)
  - gitaly (0.1.0)
  - praefect (0.1.0)
  - gitlab-kas (0.1.0)
  - letsencrypt (0.1.0)

Start the Gitlab Services

gitlab-ctl start

Output:

root@crown:~#gitlab-ctl start
ok: run: alertmanager: (pid 61628) 0s
ok: run: gitaly: (pid 61319) 25s
ok: run: gitlab-exporter: (pid 61284) 26s
ok: run: gitlab-workhorse: (pid 61261) 27s
ok: run: grafana: (pid 61368) 20s
ok: run: logrotate: (pid 59471) 404s
ok: run: nginx: (pid 59983) 218s
ok: run: node-exporter: (pid 61269) 27s
ok: run: postgres-exporter: (pid 61361) 21s
ok: run: postgresql: (pid 59709) 379s
ok: run: prometheus: (pid 61310) 25s
ok: run: puma: (pid 59903) 237s
ok: run: redis: (pid 59532) 397s
ok: run: redis-exporter: (pid 61286) 25s
ok: run: sidekiq: (pid 59922) 230s

Check the status of Gitlab Services

gitlab-ctl status

Output:

root@crown:~# gitlab-ctl status
down: alertmanager: 1s, normally up, want up; run: log: (pid 60138) 226s
run: gitaly: (pid 61319) 78s; run: log: (pid 59578) 439s
run: gitlab-exporter: (pid 61284) 79s; run: log: (pid 60057) 250s
run: gitlab-workhorse: (pid 61261) 80s; run: log: (pid 59959) 274s
run: grafana: (pid 61368) 73s; run: log: (pid 60761) 147s
run: logrotate: (pid 59471) 457s; run: log: (pid 59502) 454s
run: nginx: (pid 59983) 271s; run: log: (pid 59997) 268s
run: node-exporter: (pid 61269) 80s; run: log: (pid 60037) 260s
run: sidekiq: (pid 59922) 283s; run: log: (pid 59935) 280s

Now navigate to your browser to set the new password http://IP_address

Replace IP_address with you actual IP Address of the server.

Default user is root and the Password that was just set,

Output:

gitlab1

Reset Password for User

Example:

In case you’ve forgotten the password to any of your users, you can use the below Rake task to reset it.

gitlab-rake "gitlab:password:reset"

Example:

sudo gitlab-rake 'gitlab:password:reset[root]'

bookmark_borderUbuntu 22.04 is now available on OpenVZ-based VPSes

Hey There!


We’re happy to announce that Ubuntu 22.04 is now available as an operating system choice on our OpenVZ-based plans in our control panel.

We also have a few guides available on our wiki to start off with Ubuntu 22.04Click Here — Feel free to contact our support team (via a support ticket) if you wish to see any new/different guides available on our wiki!

Stay tuned for more!
– Team CrownCloud

bookmark_borderInstalling Webmin on AlmaLinux 9

Hello,

In this week’s feature highlight, we look at How to Install Webmin on AlmaLinux 9

Webmin is a web-based dashboard that allows sysadmins to manage Linux and Unix-like systems (especially servers). Webmin allows system administrators to manage user accounts, update packages, system log files, configure firewalls, email, database, postfix, etc.

First, check for any pending system updates,

dnf update

install Webmin using the following command:

yum install webmin

Access the Webmin Web Interface.

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

To start Webmin, you can use the following command:

service webmin start

To access Webmin, open the URL from your web browser: https://IP_address:10000

Note:

  1. When logging in for the first time, you will see an ‘invalid SSL’ warning.
  2. Simply click on the ‘Advanced’ tab and then ‘Accept the risk and Continue’.

Login to the Webmin web interface using your root user and password.

First

Once you log in, you will be redirected to the Webmin dashboard.

First

bookmark_borderInstalling AlmaLinux 9

Hello,

In this week’s feature highlight, we look at How to Install AlmaLinux 9.

Login to your Panel (https://crownpanel.com/)

To start the installation, first mount the AlmaLinux ISO.

Mounting the AlmaLinux ISO Image

To mount the ISO select the CD-ROM Tab and select the AlmaLinux ISO from the drop-down named AlmaLinux 9 x86_64 and click on Mount button.

Please note: The ISO mount may take upto 2-3 minutes to complete.

ab

Once the ISO has mounted (Task Log tab will show the status of the task), navigate to “Power Control” tab and then perform a Reboot task on the server.

Now, Switch to the VNC Tab and click on “Launch VNC” to launch the web based VNC console to start the AlmaLinux installation.

If the VPS hasn’t booted yet into the AlmaLinux installer, please click on the CTRL+ALT+DEL button from the VNC console to send a reboot signal to the VPS to boot into the installer.

Once we have booted into the AlmaLinux installer,

Select “Install AlmaLinux”

Select the desired language and click on continue.

Select Network & Hostname and configure.

If you would like to keep the Network Dynamic / DHCP (default configuration), Enable the network and click on Done.

Disk Partitioning Configuration

After Select Installation & Destination.

Select standard Partition and assign disk required and done.

Then select Accept changes.

Installation Source Configuration

After Select Installation Source.

Select auto detected installation media -> verify -> Minimal and press done.

Software Selection

After Select Software Selection–>minimal install and press done.

Login Password Configuration

select the root password to set ‘root’ password.

Begin Installation

And Begin Installation.

After installation is completed unmount the ISO and reboot the server. Wait for a few minutes for the reboot to complete, after which you will see the login prompt.

Note: You can also use SSH to connect to your VPS at this point.

Done!

bookmark_borderInstalling Netdata on Ubuntu 22.04

Hello,

In this week’s feature highlight, we look at How To Install Netdata on Ubuntu 22.04

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.

Update the Server

Let us update the server using the following command,

apt update -y

apt upgrade -y

Download Netdata Package

Install Netdata on the server using below command.

apt install netdata -y

The -y option is used for the confirmation which will be prompted by the installer.

Netdata Configuration

We need a small change in the configuration file, so that the dashboard is available on a public IP.

If you intend to use this locally, then you do not need to make this change.

nano /etc/netdata/netdata.conf 

Configuration file will look like this.

[global]
        run as user = netdata
        web files owner = root
        web files group = root
        # Netdata is not designed to be exposed to potentially hostile
        # networks. See https://github.com/netdata/netdata/issues/164
        bind socket to IP = 127.0.0.1

By default, the bind socket to IP it set to 127.0.0.1. To access the dashboard using the IP address, you need to replace 127.0.0.1 with your actual server IP Address.

[global]
        run as user = netdata
        web files owner = root
        web files group = root
        # Netdata is not designed to be exposed to potentially hostile
        # networks. See https://github.com/netdata/netdata/issues/164
        bind socket to IP = <Enter your IP address here>

Save the file and restart the netdata service using the below command.

systemctl restart netdata 

Firewall

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

ufw allow 19999

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,

images

bookmark_borderUbuntu 22.04 Template now available for KVM Based VPS

Hey There!
We’re happy to announce that Ubuntu 22.04 is now available as an operating system choice on our KVM-based plans in our control panel.

Please refer to the following guide to install the operating system on KVM based VPSes using our Control Panel, Click Here.

Stay tuned for further updates!

Follow us on CrownCloud BlogTwitter, and Facebook for updates regarding current offers and other updates.

bookmark_borderInstalling PostgreSQL on Ubuntu 22.04

Hello,
In this week’s feature highlight, we look at How To Install PostgreSQL on Ubuntu 22.04

PostgreSQL is a powerful, open-source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

Install PostgreSQL on Ubuntu

Install PostgreSQL on Ubuntu by using the following command

apt update

apt install postgresql postgresql-contrib

Output:

root@crown:~# apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
postgresql-contrib is already the newest version (13+225ubuntu1).
The following packages were automatically installed and are no longer required:
  libfile-find-rule-perl libnumber-compare-perl libtext-glob-perl
Use 'apt autoremove' to remove them.
Suggested packages:
  postgresql-doc
The following NEW packages will be installed:
  postgresql 

PostgreSQL Roles and Databases

We’ll switch to Postgres account for the next steps, to switch to the postgres account, use the following command,

sudo -i -u postgres

You can access a PostgreSQL prompt using the psql utility

psql

Output:

postgres@crown:~$ psql
psql (14.2 (Ubuntu 14.2-1))
Type "help" for help.

postgres=#

Exit out of the PostgreSQL shell type

\q

Create PostgreSQL Role,

sudo -u postgres createuser --interactive

Output:

Enter name of role to add: john
Shall the new role be a superuser? (y/n) y

Create a PostgreSQL database,

sudo -u postgres createdb john

Open a Postgres Prompt with the New Role.

sudo adduser john

Switch over and connect to the database.

sudo -u john psql

Output:

root@crown:~# sudo -u john psql
could not change directory to "/root": Permission denied
psql (14.2 (Ubuntu 14.2-1))
Type "help" for help.

john=#

Once you logged in as john and check your current connection information.

\conninfo

Output:

john=# \conninfo
You are connected to database "john" as user "john" via socket in "/var/run/postgresql" at port "5432".
john=#

bookmark_borderInstalling LEMP Stack (Nginx, MariaDB, PHP8.1) on Ubuntu 22.04

Hello,
In this week’s feature highlight, we look at How to Install LEMP Stack (Nginx, MariaDB, PHP8.1) on Ubuntu 22.04

LEMP Stack is a combination of free, open source software. The acronym LEMP refers to the first letters of Linux (Operating system), Nginx Server, MySQL (database software), and PHP, PERL or Python, principal components to build a viable general purpose web server.

Updating the system

We first update the system to make sure that all our installed packages are up to date. Your Ubuntu system can be updated easily with the following command.

apt update

apt upgrade

Install Nginx

We will start by installing the Nginx web server. To complete the installation, use the following command.

apt install nginx

Output:

root@crown:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3
  libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2 libtiff5
  libwebp7 libxpm4 nginx-common nginx-core
Suggested packages:
  libgd-tools fcgiwrap nginx-doc ssl-cert

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

systemctl start nginx

systemctl enable nginx

systemctl status nginx

Output:

 root@crown:~#     systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-03-17 14:43:23 UTC; 36min ago
       Docs: man:nginx(8)
    Process: 42595 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=ex>
    Process: 42596 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, sta>
   Main PID: 42597 (nginx)
      Tasks: 2 (limit: 1074)
     Memory: 2.8M
        CPU: 34ms
     CGroup: /system.slice/nginx.service
             ├─42597 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─42598 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "">

Check the Nginx version,

nginx -v

Output:

root@crown:~#     nginx -v
nginx version: nginx/1.18.0 (Ubuntu)

Verify that the webserver is running and accessible by accessing your server’s IP address.

From your browser,

http://IP_address
image

we need to make the user Nginx the owner of the web directory. By default, it’s owned by the root user.

chown www-data:www-data /usr/share/nginx/html -R

Install MariaDB Server

MariaDB is a popular database server. The installation is simple and requires just a few steps as shown.

apt install mariadb-server mariadb-client

Output:

root@crown:~# apt install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  galera-4 libcgi-fast-perl libcgi-pm-perl libclone-perl
  libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
  libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libndctl6 libpmem1
  libsnappy1v5 libtimedate-perl liburi-perl liburing2 mariadb-client-10.6
  mariadb-client-core-10.6 mariadb-common mariadb-server-10.6
  mariadb-server-core-10.6 mysql-common socat

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

systemctl start mariadb

systemctl enable mariadb

systemctl status mariadb

Output:

root@crown:~# systemctl status mariadb
● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-03-17 13:37:36 UTC; 1h 37min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 26174 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 7 (limit: 1074)
     Memory: 57.2M
        CPU: 1.671s
     CGroup: /system.slice/mariadb.service
             └─26174 /usr/sbin/mariadbd

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

mysql_secure_installation

Output:

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!

Once secured, you can connect to MySQL and review the existing databases on your database server by using the following command.

mysql -e "SHOW DATABASES;" -p

Output:

root@vps:~# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+

Install PHP 8.1

To Install PHP 8.1, use the command.

apt install php php-fpm php-mysql php-common php-cli php-common php-json php-opcache php-readline php-mbstring php-xml php-gd php-curl

To start php8.1-fpm.

systemctl start php8.1-fpm

To auto-start on boot php8.1-fpm.

systemctl enable php8.1-fpm

To Check status.

systemctl status php8.1-fpm

Output:

 root@crown:~# systemctl status php8.1-fpm
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor pr>
     Active: active (running) since Thu 2022-03-17 14:12:02 UTC; 57min ago
       Docs: man:php-fpm8.1(8)
   Main PID: 41457 (php-fpm8.1)
     Status: "Processes active: 0, idle: 2, Requests: 1, slow: 0, Traffic: 0req>
      Tasks: 3 (limit: 1074)
     Memory: 11.6M
        CPU: 359ms
     CGroup: /system.slice/php8.1-fpm.service
             ├─41457 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" >
             ├─41458 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "">
             └─41459 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "">

Setting Up Server Blocks

You need to remove the file default, located in /etc/nginx/sites-enabled.

rm /etc/nginx/sites-enabled/default

Create new server block file under /etc/nginx/conf.d/ directory.

nano /etc/nginx/conf.d/default.conf

Add the following text to the file.

  server {
  listen 80;
  listen [::]:80;
  server_name _;
  root /var/www/html/;
  index index.php index.html index.htm index.nginx-debian.html;

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  }

 # A long browser cache lifetime can speed up repeat visits to your page
  location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
       access_log        off;
       log_not_found     off;
       expires           360d;
  }

  # disable access to hidden files
  location ~ /\.ht {
      access_log off;
      log_not_found off;
      deny all;
  }
}

Next, test to make sure that there are no syntax errors in any of your Nginx files.

nginx -t

If there aren’t any problems, restart Nginx to enable your changes.

systemctl reload nginx

Test PHP

To test PHP-FPM with the Nginx Web server, we need to create an info.php file in the webroot directory.

nano /var/www/html/info.php

Add the following PHP code to the file.

<?php phpinfo(); ?>

Now again, access http://localhost/info.php or http://yourserver-ip-address/info.php. You should see a page similar to the below one.

image

This concludes the installation of LEMP Stack on Ubuntu 22.04 server.

bookmark_borderInstalling LAMP Stack with MariaDB on Ubuntu 22.04

Hello,

In this week’s feature highlight, we look at How to Install LAMP Stack with MariaDB on Ubuntu 22.04

A LAMP stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL or MariaDB database, and dynamic content is processed by PHP.

First, check for any pending system upgrades.

apt update
apt upgrade

Install Apache

Command to install Apache along with its utilities.

apt install -y apache2 apache2-utils

Next, check the Status of Apache.

systemctl status apache2

Output:

root@server:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-03-14 21:07:34 UTC; 45min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 22154 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 22158 (apache2)
      Tasks: 7 (limit: 1074)
     Memory: 13.7M
        CPU: 294ms
     CGroup: /system.slice/apache2.service
             ├─22158 /usr/sbin/apache2 -k start
             ├─22159 /usr/sbin/apache2 -k start
             ├─22160 /usr/sbin/apache2 -k start
             ├─22161 /usr/sbin/apache2 -k start
             ├─22162 /usr/sbin/apache2 -k start
             ├─22163 /usr/sbin/apache2 -k start
             └─22195 /usr/sbin/apache2 -k start

If Apache is not active can start using the following command.

systemctl start apache2

Use the following command to auto start Apache at boot time.

systemctl enable apache2

You can confirm the Apache2 version with the below command,

apache2 -v

Output:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-02-03T18:25:47

Enable and Configure Firewall

To enable HTTP TCP port,

ufw allow http

Output:

Rules updated Rules updated (v6) Now you can verify whether the apache is installed correctly or not by opening it in a web browser.

http://ip-address

NOTE: Replace with your Server IP address.

images

Install MariaDB Server

To install MariaDB server, run the below command:

apt install mariadb-server mariadb-client

To check the status of MariaDB.

systemctl status mariadb

Output:

root@server:~# systemctl status mariadb

● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-03-14 20:55:55 UTC; 57min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 14311 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 7 (limit: 1074)
     Memory: 57.2M
        CPU: 1.266s
     CGroup: /system.slice/mariadb.service
             └─14311 /usr/sbin/mariadbd

To start MariaDB if it is not active.

systemctl start mariadb

Use the following command to auto start MariaDB at boot time.

systemctl enable mariadb

Next, MariaDB database security.

NOTE: In this step, you will be prompted with several questions.

mysql_secure_installation

Output:

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!

To login to MariaDB.

 mariadb -u root -p

To exit from MariaDB.

exit

To check MariaDB Version.

mariadb --version

Output:

root@server:~# mariadb --version
mariadb  Ver 15.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Install PHP

PHP 8.1 is the default version of PHP that would be installed on Ubuntu 22.04.

To install PHP.

apt install php libapache2-mod-php php-mysql php-common php-cli php-common php-json php-opcache php-readline

To Enable the Apache PHP module and restart the Apache Web server.

a2enmod php
systemctl restart apache2

To check PHP Version.

php --version

Output:

root@crown:~# php --version
PHP 8.1.0 (cli) (built: Nov 25 2021 19:57:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies

To test PHP scripts we need to add the info.php file in the document.

nano /var/www/html/info.php

Add the following to the file.

<?php phpinfo(); ?>

To verify enter the following link in a web browser.

NOTE: Replace with your server IP address below.

http://ip-address/info.php
images

Run PHP-FPM with Apache [Optional]

FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.

NOTE: This is an optional step, PHP 8.1 is used to run the PHP code but if you want to run PHP code with PHP-FPM follow the below steps.

First, Let us disable PHP,

a2dismod php

Next, Install PHP-FPM.

apt install php8.1-fpm

Enable proxy_fcgi and setenvif module.

a2enmod proxy_fcgi setenvif

Output:

Considering dependency proxy for proxy_fcgi:
Enabling module proxy.
Enabling module proxy_fcgi.
Module setenvif already enabled
To activate the new configuration, you need to run:
  systemctl restart apache2

To enable php8.1-fpm file.

a2enconf php8.1-fpm

Restart the Apache.

systemctl restart apache2

To enable php-fpm.

systemctl enable php8.1-fpm

To start php-fpm.

systemctl start php8.1-fpm

To check the status of php-fpm.

systemctl status php8.1-fpm

Output:

root@crown:~# systemctl status php8.1-fpm
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-03-14 22:16:17 UTC; 29s ago
       Docs: man:php-fpm8.1(8)
   Main PID: 24942 (php-fpm8.1)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 1074)
     Memory: 7.3M
        CPU: 48ms
     CGroup: /system.slice/php8.1-fpm.service

Now you have successfully installed the LAMP stack (Apache, MariaDB, and PHP8.1) on Ubuntu 22.04.

bookmark_borderHow to Install WordPress on Ubuntu 22.04

Hello,

In this week’s feature highlight, we look at How to Install WordPress on Ubuntu 22.04

WordPress is one of the most popular website-building tools available out there. It is a simple way to get your online presence and perfect for those who do not know how to code and want a simple and effective way to share and build your story on the internet.

Prerequisites:

Creating Database

Log into MySQL with the following command.

mysql -u root -p

First, we’ll create a new database.

CREATE DATABASE wordpress_db;

Next, create a new MySQL user account that we will use to operate on WordPress’s new database, with the username “wordpress_user”.

CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';

Link the user and DB together by granting our user access to the database.

GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';

Flush the privileges so that MySQL knows about the user permissions we just added.

FLUSH PRIVILEGES;

Exit out of the MySQL command prompt by typing.

exit

Output:

root@crown:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 81
Server version: 10.6.7-MariaDB-2ubuntu1 Ubuntu 22.04

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 wordpress_db;
Query OK, 1 row affected (0.003 sec)

MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Query OK, 0 rows affected (0.003 sec)

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

MariaDB [(none)]> exit
Bye

Download and install WordPress

Download WordPress.

wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz

Unzip the downloaded WordPress file.

tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html

Change the permission of the site directory.

chown -R www-data.www-data /var/www/html/wordpress

Navigate to your browser.

http://IP_ADDRESS/wordpress

images

Start a WordPress installation by clicking on the Run the installation button.

images

Provide the requested information.

images

Once WordPress is installed log in with your new user credentials.

images
images