bookmark_borderInstalling LAMP Stack with MariaDB on Ubuntu 23.04


In this week’s feature highlight, we look at How to Install LAMP Stack with MariaDB on Ubuntu 23.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


root@ubuntu:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enab>
     Active: active (running) since Fri 2023-04-14 15:36:54 UTC; 3min 6s ago
   Main PID: 2067 (apache2)
      Tasks: 55 (limit: 3386)
     Memory: 5.1M
        CPU: 191ms
     CGroup: /system.slice/apache2.service
             ├─2067 /usr/sbin/apache2 -k start
             ├─2068 /usr/sbin/apache2 -k start
             └─2070 /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


root@ubuntu:~# apache2 -v
Server version: Apache/2.4.55 (Ubuntu)
Server built:   2023-03-08T16:32:34

Enable Firewall

We will open the HTTP port in the firewall, so we can access the page served by the Apache web server.

Allow the HTTP port by running the below command,

ufw allow http


Rules updated
Rules updated (v6)

And to verify if it’s working, open the server’s IP address in your browser. You should be able to view the Apache default page.


NOTE: Replace with your Server IP address.


Install MariaDB Server

Install MariaDB server, run the below command:

apt install mariadb-server mariadb-client

Once the installation complete, check the status of MariaDB.

systemctl status mariadb


root@ubuntu:~# systemctl status mariadb

● mariadb.service - MariaDB 10.11.2 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enab>
     Active: active (running) since Fri 2023-04-14 18:11:18 UTC; 22s ago
       Docs: man:mariadbd(8)
   Main PID: 4880 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 17 (limit: 3386)
     Memory: 79.2M
        CPU: 1.439s
     CGroup: /system.slice/mariadb.service
             └─4880 /usr/sbin/mariadbd

Start MariaDB if it is not active using below command,

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.



root@ubuntu:~# mysql_secure_installation


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
haven't set the root password yet, you should just press enter here.

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

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
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!

Login to the MariaDB using below command,

 mariadb -u root -p

To exit from MariaDB.


Check MariaDB Version,

mariadb --version


root@ubuntu:~# mariadb --version
mariadb  Ver 15.1 Distrib 10.11.2-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper

Install PHP

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

Install PHP and Required Extensions using below command,

apt install php libapache2-mod-php php-mysql php-common php-cli php-common php-json php-opcache php-readline php-mbstring php-gd php-dom php-zip php-curl

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

systemctl restart apache2

To check PHP Version.

php --version


root@ubuntu:~# php --version
PHP 8.1.12-1ubuntu4 (cli) (built: Feb 22 2023 19:48:21) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.12-1ubuntu4, Copyright (c), by Zend Technologies

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.


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.

Next, Install PHP-FPM.

apt install php8.1-fpm

Enable proxy_fcgi and setenvif module.

a2enmod proxy_fcgi setenvif


root@ubuntu:~# a2enmod proxy_fcgi setenvif
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

Now enable php8.1-fpm file.

a2enconf php8.1-fpm

Restart the Apache.

systemctl restart apache2

Enable php-fpm.

systemctl enable php8.1-fpm

Follow below command to start php-fpm.

systemctl start php8.1-fpm

To check the status of php-fpm.

systemctl status php8.1-fpm


root@ubuntu:~# 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; preset: e>
     Active: active (running) since Fri 2023-04-14 18:30:47 UTC; 1min 32s ago
       Docs: man:php-fpm8.1(8)
   Main PID: 17796 (php-fpm8.1)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req>
      Tasks: 3 (limit: 3386)
     Memory: 9.5M
        CPU: 133ms
     CGroup: /system.slice/php8.1-fpm.service
             ├─17796 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)"
             ├─17797 "php-fpm: pool www"
             └─17798 "php-fpm: pool www"

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

bookmark_borderInstalling PostgreSQL on Ubuntu 22.10


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

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

Install PostgreSQL on Ubuntu by using the following command

apt update

apt install postgresql postgresql-contrib


root@crown:~# apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  galera-4 libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
  libmariadb3 libmysqlclient21 libndctl6 libpmem1 libsnappy1v5 liburing2
  mariadb-common socat
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  libcommon-sense-perl libjson-perl libjson-xs-perl libllvm14 libpq5
  libsensors-config libsensors5 libtypes-serialiser-perl postgresql-14
  postgresql-client-14 postgresql-client-common postgresql-common sysstat

PostgreSQL Roles and Databases

We’ll switch to the Postgres user 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



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


To exit the postgres shell, use the below command,


Create PostgreSQL Role

Now let us see how we can create additional users that can interact with the Databases.

For this, you have to be a postgres user and then run the command as shown below,

createuser --interactive


postgres@vps:~$ createuser --interactive
Enter name of role to add: adam
Shall the new role be a superuser? (y/n) y

Create a PostgreSQL Database

Creating a database is as simple as it gets. Run the below command as a postgres user account.

createdb database_name


postgres@vps:~$ createdb my_db

Open a Postgres Prompt with the New Role

For this, we will create a new Linux system user by using adduser.

For simplicity purpose, we will be using the same name as which we created the postgres role with, adam.

You will need to switch back to root user or a sudo user with required privileges .

adduser username


root@vps:~# adduser adam
Adding user `adam' ...
Adding new group `adam' (1000) ...
Adding new user `adam' (1000) with group `adam' ...
Creating home directory `/home/adam' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

Switch over to the newly added user and connect to the database.

sudo -u username

Open the postgres shell and connect to the new Database,

psql -d database_name


root@vps:~# sudo -i -u adam

adam@vps:~$ psql -d my_db
psql (14.5 (Ubuntu 14.5-1ubuntu1))
Type "help" for help.


Once you’re logged in as adam, check your current connection information:



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

This concludes the topic on installing PostgreSQL on Ubuntu.

bookmark_borderInstalling PhpMyAdmin in Ubuntu 22.10


In this week’s feature highlight, we look at How to Install PhpMyAdmin in Ubuntu 22.10

In this guide, we will demonstrate how PhpMyAdmin is installed on a Ubuntu 22.10 system. PhpMyAdmin requires a standalone Database or as part of the LEMP stack, installed and running on the system beforehand.


Server with Apache, PHP, and MariaDB. You can find our LAMP Installation guide here.

Installing PhpMyAdmin

apt install phpmyadmin


root@crown:~# apt install phpmyadmin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dbconfig-common dbconfig-mysql icc-profiles-free javascript-common
libjs-jquery libjs-openlayers libjs-sphinxdoc libjs-underscore libzip5
php-bz2 php-google-recaptcha php-mysql php-phpmyadmin-motranslator
php-phpmyadmin-shapefile php-phpmyadmin-sql-parser php-phpseclib
php-psr-cache php-psr-container php-psr-log php-symfony-cache
php-symfony-cache-contracts php-symfony-expression-language

Create Symbolic Link

Create a symbolic link from the installation files to Nginx’s document root directory.

ln -s  /usr/share/phpmyadmin /var/www/html/phpmyadmin

Enter it into your browser’s address bar to check that phpmyadmin is installed. http://yourserver-ip-address/phpmyadmin/. You should see a page similar to the below one.