PrestaShop on Ubuntu 22.04

How to Install PrestaShop on Ubuntu 22.04

PrestaShop is an open-source platform that allows anybody to easily create an e-commerce website platform to start selling products. The software was created with PHP and released under the Open Software License (OSL).

In this tutorial, we will explain how to install and configure the PrestaShop e-commerce platform on Ubuntu 22.04.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to the latest version with the following command:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Nginx webserver

You can install it via apt package manager by executing the following command.

$ sudo apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

$ sudo systemctl start nginx
$ sudo systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

$ sudo systemctl status nginx

Output:

● 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)
       Docs: man:nginx(8)
    Process: 835 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1059 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1060 (nginx)
      Tasks: 2 (limit: 2200)
     Memory: 7.9M
        CPU: 94ms
     CGroup: /system.slice/nginx.service
             ├─1060 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─1061 "nginx: worker process"

Step 3: Install PHP and PHP extensions for PrestaShop

By default, Ubuntu 22.04 comes with PHP version 8.1.

However, PrestaShop requirement PHP7.4. So you will need to add the DEB.SURY.ORG repository to APT.

$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php -y

To install PHP and additional PHP modules to support PrestaShop, run the following command:

$ sudo apt-get install php7.4 php7.4-{cli,fpm,common,curl,zip,gd,mysql,xml,mbstring,json,intl}

Verify if PHP is installed.

php7.4 -v
Output:
PHP 7.4.30 (cli) (built: Aug  1 2022 15:06:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies

After installing all the packages, edit the php.ini file:

$ sudo nano /etc/php/7.4/fpm/php.ini

Change the following settings per your requirements:

memory_limit = 512M
post_max_size = 32M
upload_max_filesize = 32M
date.timezone = America/Chicago

Step 4: Install MariaDB and create a database

MariaDB is a free and opensource database engine that is flexible, robust and easy-to-use. To install MariaDB run the following command:

$ sudo apt install mariadb-server mariadb-client

Verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 22956 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2200)
     Memory: 57.0M
        CPU: 447ms
     CGroup: /system.slice/mariadb.service
             └─22956 /usr/sbin/mariadbd

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.

$ sudo mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] Y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y

Now run the command below to log in to the MariaDB shell.

$ sudo mysql -u root -p

Once you are logged in to your database server you need to create a database for the PrestaShop installation:

MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'Str0ngWedrf1';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop. * TO 'prestashop'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Step 5: Download PrestaShop

The latest version of PrestaShop is available to download from their website. As of writing this tutorial, the latest version available is 1.7.8.7.

$ sudo wget https://www.prestashop.com/en/system/files/ps_releases/prestashop_1.7.8.7.zip

Then extract file into the folder /var/www/prestashop/ with the following command:

$ sudo apt -y install unzip 
$ sudo unzip prestashop_1.7.8.7.zip -d /var/www/prestashop/

Enable permission for the Nginx webserver user to access the files:

$ sudo chown -R www-data:www-data /var/www/prestashop/

Step 6: Configure Nginx for PrestaShop

Run the commands below to create a new VirtualHost file called prestashop in the /etc/nginx/conf.d/ directory.

$ sudo nano /etc/nginx/conf.d/prestashop.conf

Paste the content as shown below:

server {
    listen 80;
    server_name your-domain.com;

    access_log /var/log/nginx/your-domain.com-access.log;
    error_log /var/log/nginx/your-domain.com-error.log;

    root /var/www/prestashop;

    index index.php;

    client_max_body_size 16M;

    error_page 404 /index.php?controller=404;

    rewrite ^/(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last;
    rewrite ^/(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
    rewrite ^/(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/c/([\w.-]+)/.+\.jpg$ /img/c/$1.jpg last;

    rewrite ^images_ie/?([^/]+)\.(gif|jpe?g|png)$ js/jquery/plugins/fancybox/images/$1.$2 last;

    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

    rewrite ^(/install(?:-dev)?/sandbox)/.* /$1/test.php last;

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

    location /admin-dev/ {
        if (!-e $request_filename) {
            rewrite ^ /admin-dev/index.php last;
        }
    }

    location ~ /\. {
        deny all;
    }

    location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|var|vendor)/ {
        deny all;
    }

    location ~ ^/modules/.*/vendor/ {
        deny all;
    }

    location ~ \.(log|tpl|twig|sass|yml)$ {
        deny all;
    }

    location /img {
        location ~ \.php$ { deny all; }
    }

    location /upload {
        location ~ \.php$ { deny all; }
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

        try_files $fastcgi_script_name =404;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;

        fastcgi_index index.php;

        fastcgi_keep_conn on;
        fastcgi_read_timeout 180s;
        fastcgi_send_timeout 180s;

        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
}

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

To implement the changes, restart Nginx webserver:

$ sudo systemctl restart nginx

Step 7: Access PrestaShop Web Interface

Open your web browser and type the URL http://your-domain.com. You should see the following page:

Choose your language and click on Next.

Accept the license and click on the Next.

Provide your site information and click on the Next.

Provide your database information and click on the Next.

Click on the “Manage your store“. But as we try to login, an error appears “For security reasons, you cannot login to the back office until you delete the installation folder

To delete the installation folder, run the command below on the server:

$ sudo rm -r /var/www/prestashop/install

After deleting the folder just refresh the login page and this time you will get the login page.

Provide your admin username and password and click on LOG IN. You will be redirected to the dashboard:

Comments and Conclusion

Congratulations! You have successfully installed PrestaShop e-commerce platform. Thanks for using this tutorial for installing the PrestaShop on your Ubuntu 22.04 OS.

How to Install DokuWiki with Nginx on Ubuntu 22.04

DokuWiki is a free and open-source wiki software written in PHP that allows users to create and edit pages using a web browser. It is easy to install and use, and doesn’t require a database since it works on plain text files. Using a very familiar interface, allows you to easily scale and optimize using many advanced features.

The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges.

Step 1: Update Operating System

Update and upgrade your system packages to the latest version with the following command:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Nginx Web Server

In this tutorial, we will use Nginx. If you prefer Apache or another web server, you can use that instead of Nginx.

You can install Nginx via apt package manager by executing the following command.

$ sudo apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

$ sudo systemctl start nginx
$ sudo systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

$ sudo systemctl status nginx

Output:

● 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)
       Docs: man:nginx(8)
   Main PID: 11940 (nginx)
      Tasks: 2 (limit: 2200)
     Memory: 2.6M
        CPU: 63ms
     CGroup: /system.slice/nginx.service
             ├─11940 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─11941 "nginx: worker process

Step 3: Install PHP and required PHP extensions for DokuWiki

By default, the Ubuntu 22.04 repositories provide PHP 8.x. Please note that Dokuwiki is not yet compatible with PHP 8.

To install PHP 7.4 you need to install SURY, third party repositories to APT.

First, install the required packages using the following command:

$ sudo apt-get install ca-certificates apt-transport-https software-properties-common -y

Once all the packages are installed, add a Sury repository to APT using the following command:

$ sudo add-apt-repository ppa:ondrej/php --yes &> /dev/null

Once you are done, update the repository with the following command:

$ sudo apt-get update -y

Now, you can install the PHP 7.4 and additional PHP modules using the following command:

$ sudo apt-get install php7.4 php7.4-fpm php7.4-gd php7.4-xml php7.4-json

Verify the PHP version:

php7.4 -v
Output:
PHP 7.4.30 (cli) (built: Jun 27 2022 08:21:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies

Step 4: Download DokuWiki

Download the latest version from DokuWiki download’s page using the following command:

$ sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

Create a folder to store web root files:

$ sudo mkdir /var/www/html/dokuwiki

Then extract DokuWiki tarball file into the folder /var/www/html/dokuwiki/ with the following command:

$ sudo tar xzf dokuwiki-stable.tgz -C /var/www/html/dokuwiki/ --strip-components=1

Change ownership of /var/www/html/dokuwiki to www-data user and group:

$ sudo chown -R www-data:www-data /var/www/html/dokuwiki/

Step 5: Configure Nginx for DokuWiki

Then, create an virtual host configuration file to host DokuWiki:

$ sudo nano /etc/nginx/conf.d/dokuwiki.conf

Paste the content as shown below:

server {
  server_name your-domain.com;
  root /var/www/html/dokuwiki;

  location / {
    index doku.php;
    try_files $uri $uri/ @dokuwiki;
  }

  location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
    expires 30d;
  }

  location ^~ /conf/ { return 403; }
  location ^~ /data/ { return 403; }

  location @dokuwiki {
    rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
    rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
    rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
    rewrite ^/(.*) /doku.php?id=$1 last;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;;
  }
}

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

Check Nginx syntax:

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

To implement the changes, restart Nginx webserver:

$ sudo systemctl restart php7.4-fpm nginx

Step 6: Access DokuWiki Web Interface

To complete the setup go to your browser and visit http://your-domain.com/install.php.

Provide all the required information like superuser name, email, password. Ensure you select the correct ACL policy. Then, click on the Save button.

Once the installation has been completed successfully, click “your new DokuWiki” to get to home page.

To login to your dashboard, click Log in at the top right corner.

Enter your username and password your created earlier and click on the Log In button:

You should see the dashboard in the following screen:

After a successful configuration, delete the install.php file from the DokuWiki root directory:

sudo rm -f /var/www/html/dokuwiki/install.php

Comments and Conclusion

Congratulations! You have successfully installed and configured DokuWiki on Ubuntu 22.04. Thanks for using this tutorial for installing the DokuWiki on Ubuntu 22.04 OS.

How to Install OpenCart on Ubuntu 22.04

OpenCart is a popular open-source and free to use content management system (CMS) designed for building online stores.

It offers a lot of plugins that help you to extend the platform’s functionality and includes features like user management, multi-store functionality, affiliates, discounts, multiple payment gateways, product reviews, and more.

In this tutorial, we will explain how to install and configure the OpenCart e-commerce platform on Ubuntu 22.04.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to the latest version with the following command:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

The Apache HTTP Server is a free and open-source cross-platform web server. You can install it via apt package manager by executing the following command.

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 2975 (apache2)
      Tasks: 55 (limit: 2200)
     Memory: 4.8M
        CPU: 137ms
     CGroup: /system.slice/apache2.service
             ├─2975 /usr/sbin/apache2 -k start
             ├─2977 /usr/sbin/apache2 -k start
             └─2978 /usr/sbin/apache2 -k start

Step 3: Install PHP

To install PHP and additional PHP modules to support OpenCart, run the following command:

$ sudo apt-get install php php-cli libapache2-mod-php php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl php-xmlrpc

Verify if PHP is installed.

php -v
Output:
PHP 8.1.2 (cli) (built: Jun 13 2022 13:52:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

MariaDB is a free and opensource database engine that is flexible, robust and easy-to-use. To install MariaDB run the following command:

$ sudo apt install mariadb-server mariadb-client

Verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 26067 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 26069 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 26072 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && >
    Process: 26149 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 26151 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 26109 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 7 (limit: 2200)
     Memory: 61.3M
        CPU: 2.585s
     CGroup: /system.slice/mariadb.service
             └─26109 /usr/sbin/mariadbd

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.

$ sudo mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] Y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y

Now run the command below to log in to the MariaDB shell.

$ sudo mysql -u root -p

Once you are logged in to your database server you need to create a database for the OpenCart installation:

MariaDB [(none)]> CREATE DATABASE opencart;
MariaDB [(none)]> CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'Your-Strong-Password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Step 5: Download OpenCart

You can download the latest version of OpenCart from the Git repository using the following command:

$ sudo wget https://github.com/opencart/opencart/releases/download/4.0.0.0/opencart-4.0.0.0.zip

Then extract file into the folder /var/www/html/opencart/ with the following command:

$ sudo apt -y install unzip 
$ sudo unzip opencart-4.0.0.0.zip -d /var/www/html/opencart/

Copy OpenCart configuration files:

$ sudo cp /var/www/html/opencart/upload/{config-dist.php,config.php}

$ sudo cp /var/www/html/opencart/upload/admin/{config-dist.php,config.php}

Enable permission for the Apache webserver user to access the files:

$ sudo chown -R www-data:www-data /var/www/html/opencart/

Step 6: Create Virtualhost for Opencart

Then, create an virtual host configuration file to host OpenCart:

$ sudo nano /etc/apache2/sites-available/opencart.conf

Paste the content as shown below:

<VirtualHost *:80>
    ServerAdmin admin@your-domain.com
    DocumentRoot /var/www/html/opencart/upload/
    ServerName your-domain.com
    ServerAlias www.your-domain.com

    <Directory /var/www/html/opencart/upload/>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/your-domain.com-error_log
    CustomLog /var/log/apache2/your-domain.com-access_log common
</VirtualHost>

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

To enable this site run the command:

$ sudo a2ensite opencart.conf

To implement the changes, restart Apache webserver:

$ sudo systemctl restart apache2

Step 7: Access OpenCart Web Interface

To access the OpenCart Web Interface, go to your browser and visit http://your-domain.com/.

The first page displays the license agreement. Scroll down and click Continue.

Make sure all the required PHP extensions are installed then click on the Continue button.

The next page will require you to fill in the database details. Enter the details you defined in the MariaDB database and click Continue.

Once the installation has been completed, you should see the following page:

Then if you click on the Go to your Online Shop you should see your shop page:

Or if you click on the Login to your Administration button you should see the login page:

Provide your admin username, password and click on the Login button. You should see your administration panel:

Now, open your terminal and remove the installation directory with the following command:

$ sudo rm -rf /var/www/html/opencart/upload/install/

Comments and Conclusion

Congratulations! You have successfully installed OpenCart. Thanks for using this tutorial for installing the OpenCart on Ubuntu 22.04 OS. For additional help or useful information, we recommend you to check the official OpenCart website.

How to Install ReactJS on Ubuntu 22.04

React (also known as React.js or ReactJS) is an open-source JavaScript front-end library for creating web frontend and UI components.

It is developed and maintained by the Facebook and a large community of developers. This is also useful for creating mobile applications.

In this tutorial you will learn to install and create ReactJS Application on a Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js

Node.js is required to create and run a ReactJS application.

The Node.js version included in the default Ubuntu 22.04 repositories is v12.22.9 which is an older TLS version.

We’ll install Node.js version 18.x (current stable version) on our Ubuntu OS.

Run the following command to download and execute the NodeSource installation script:

$ curl -sL https://deb.nodesource.com/setup_18.x | sudo bash - 

Next, run the following command to install the Node.js  and npm to your system:

$ sudo apt install nodejs

The nodejs package includes both the node and npm binaries.

Once done, verify the installation by running:

node -v 
Output
v18.4.0
npm -v
Output
v8.12.1

Step 3: Install ReactJS package

After installing the node and npm, you will need to install create-react-app in your system. It is a command-line utility used to create a ReactJS Application.

Run the following npm command to install the create-react-app utility:

$ sudo npm install -g create-react-app

Verify the installed version of create-react-app with the following command:

create-react-app --version

You should see the following output:

5.0.1

Step 4: Create A New ReactJS Application

You can create a ReactJS application with the following command:

$ sudo create-react-app myreactapp 

On successful application creation, you should see the following output:

Success! Created myreactapp at /home/react/myreactapp
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd myreactapp
  npm start

Happy hacking!

Step 5: Start ReactJS Application

Once you have created your application switch to that project and run npm start to start application.

cd myreactapp  npm start 

Once the application has started successfully, you should get the following output:

Compiled successfully!

You can now view myreactapp in the browser.

Local: http://localhost:3000
On Your Network: http://192.168.1.100:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

The default ReactJS application start on port 3000.

Step 6: Create a Systemd service

Next, it is a good idea to create a systemd service file to handle the ReactJS service. You can create it with the following command:

$ sudo nano /lib/systemd/system/react.service

Add the following lines:

[Unit]
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/react/myreactapp
ExecStart=/usr/bin/npm start
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and close the file and then reload the systemd daemon with the following command:

$ sudo systemctl daemon-reload

Then start the ReactJS service and activate it at system startup with the following command:

$ sudo systemctl start react
$ sudo systemctl enable react

Then check the status of the ReactJS app with the following command:

$sudo systemctl status react

You should get the following output:

● react.service
     Loaded: loaded (/lib/systemd/system/react.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 2101 (npm start)
      Tasks: 30 (limit: 2200)
     Memory: 140.0M
        CPU: 2.937s
     CGroup: /system.slice/react.service
             ├─2101 npm
             ├─2112 sh -c "react-scripts start"
             ├─2113 node /home/react/myreactapp/node_modules/.bin/react-scripts start
             └─2120 /usr/bin/node /home/react/myreactapp/node_modules/react-scripts/scripts/start.js

Step 7: Accessing ReactJS Web Interface

Once successfully installed, open your web browser using the URL http://your-ip-address:3000. You should see the React default page:

Conclusion

In this tutorial, you have learned, how to install ReactJS on your Ubuntu 22.04 system. You can now start developing your ReactJS application.

For additional information, you can check the official ReactJS website.

How to Install Moodle on Debian 11

Moodle is a popular, free, and open-source Course Management system based on PHP released under the GNU General Public License.

The Moodle platform is highly customizable and takes a modular approach to features, so it is extensible and adaptable to your needs. It is probably most popular open source learning management platform available today.

In this tutorial, we will show you how to install Moodle on your Debian 11 OS.

Step 1: Update Operating System

Update and upgrade the system repositories to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade

Step 2: Install Apache webserver

Apache web server is available on the Debian repository and can be installed via apt package manager by executing the following command:

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 459 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 666 (apache2)
      Tasks: 6 (limit: 2301)
     Memory: 24.3M
        CPU: 439ms
     CGroup: /system.slice/apache2.service
             ├─666 /usr/sbin/apache2 -k start
             ├─677 /usr/sbin/apache2 -k start
             ├─678 /usr/sbin/apache2 -k start
             ├─679 /usr/sbin/apache2 -k start
             ├─680 /usr/sbin/apache2 -k start
             └─681 /usr/sbin/apache2 -k start

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the Apache2 Debian Default Page, as seen below.

Step 3: Install PHP and PHP extensions for Moodle

By default, Debian 11 comes with PHP version 7.4.

You can install PHP and required PHP extensions using the following command:

$ sudo apt install php libapache2-mod-php php-iconv php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml php-pspell php-json php-xmlrpc

Verify if PHP is installed.

php -v
Output: PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

Step 4: Install MariaDB

We will use MariaDB as the database system for Moodle (Moodle supports MariaDB/MySQL and PostgreSQL).

You can install MariaDB with the following command:

$ sudo apt install mariadb-server mariadb-client

The commands below can be used to stop, start and enable MariaDB service to start automatically at the next boot:

$ sudo systemctl start mariadb
$ sudo systemctl stop mariadb
$ sudo systemctl enable mariadb

Also, you can verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.5.15 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 16987 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 8 (limit: 2287)
     Memory: 63.0M
        CPU: 1.403s
     CGroup: /system.slice/mariadb.service
             └─16987 /usr/sbin/mariadbd

Then open the MariaDB default configuration file:

$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Under ‘[mysqld]‘ line, paste the following configuration:

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

Save and exit, then restart MariaDB service:

$ sudo systemctl restart mariadb

Step 5: Create Database

Log into the MariaDB prompt:

$ sudo  mysql -u root

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE moodledb;
MariaDB [(none)]> CREATE USER 'moodle_user'@'localhost' IDENTIFIED BY 'Moodle_Passw0rd!';
MariaDB [(none)]> GRANT ALL ON moodledb.* TO 'moodle_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 6: Download Moodle

We will now download the latest stable Moodle version from the Moodle Official site.

Use the following command to download Moodle:

$ sudo wget https://download.moodle.org/download.php/direct/stable400/moodle-4.0.1.zip

Extract file into the folder /var/www/html/ with the following command:

$ sudo unzip moodle-4.0.1.zip -d /var/www/html/

Then, create a new directory in /var/www/html directory:

$ sudo mkdir /var/www/html/moodledata

Enable permission for the Apache webserver user to access the files:

$ sudo chown -R www-data:www-data /var/www/html/moodle/
$ sudo chmod -R 755 /var/www/html/moodle/
$ sudo chown -R www-data:www-data /var/www/html/moodledata/

Step 7: Configure Apache Web Server for Moodle

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/apache2/sites-available/moodle.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/moodle

<Directory /var/www/html/moodle/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the virtual host:

$ sudo a2ensite moodle.conf

After that, restart the Apache web server.

$ sudo systemctl restart apache2

Step 8: Access Moodle Web Installer

Open your browser type your domain e.g http://your-domain.com You will see the Moodle installation page.

Choose a language, and then click ‘Next‘:

Configure the URL, web root directory, and data directory and then click ‘Next‘:

Configure ‘Database driver‘, use MariaDB database server and then click ‘Next‘.

Type in the database information and then click ‘Next‘ to continue.

Accept the Copyright Agreement. Just click ‘Continue‘.

System Checking, checks the server configuration and all PHP extensions needed by Moodle.

 

If all the requirements are OK click ‘Continue

Make sure all results are ‘Success‘. Then click ‘Continue‘ again.

Fill in your admin info and click ‘Update profile‘.

You will be redirected to the user admin ‘Dashboard‘:

Comments and Conclusion

That’s it. You have successfully installed Moodle on Debian 11 OS.

If you have any questions please leave a comment below.

How to Install WordPress on AlmaLinux 9

WordPress is a free, open-source and one of the most popular Content Management System (CMS) written in PHP, combined with MySQL/MariaDB database. Millions of websites are currently running on it and remains perhaps the most popular CMS for blogging, which was its original use case.

In this tutorial we’ll show you how to setup a LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack and install WordPress on AlmaLinux 9 OS.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

$ sudo dnf update && sudo dnf upgrade -y

Also, install:

$ sudo dnf install nano wget unzip

Step 2: Install Apache web server on AlmaLinux 9

You can install Apache via dnf package manager by executing the following command.

$ sudo dnf install httpd

You can start the httpd service and configure it to run on startup by entering the following commands:

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

Verify the status of the httpd service using systemctl status command:

$ sudo systemctl status httpd

Output:

● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
     Active: active (running)
       Docs: man:httpd.service(8)
   Main PID: 10643 (httpd)
     Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
      Tasks: 213 (limit: 5738)
     Memory: 28.9M
        CPU: 198ms
     CGroup: /system.slice/httpd.service
             ├─10643 /usr/sbin/httpd -DFOREGROUND
             ├─10644 /usr/sbin/httpd -DFOREGROUND
             ├─10645 /usr/sbin/httpd -DFOREGROUND
             ├─10646 /usr/sbin/httpd -DFOREGROUND
             └─10647 /usr/sbin/httpd -DFOREGROUND

If firewalld is enabled consider allowing HTTP and HTTPS services:

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

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default Apache2 Page, as seen below.

Step 3: Install PHP and PHP extensions for WordPress

You can install PHP and other supporting packages using the following command:

$ sudo dnf install php php-curl php-bcmath php-gd php-soap php-zip php-curl php-mbstring php-mysqlnd php-gd php-xml php-intl php-zip

Verify if PHP is installed.

php -v

Output:

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

Step 4: Install MariaDB and create a database

You can install MariaDB with the following command:

$ sudo dnf install mariadb-server mariadb

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mariadb
$ systemctl enable mariadb

Verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 13088 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 5738)
     Memory: 73.5M
        CPU: 390ms
     CGroup: /system.slice/mariadb.service
             └─13088 /usr/libexec/mariadbd --basedir=/usr

Once the database server is installed, run the following command to secure your MariaDB server:

$ sudo mysql_secure_installation

Use the following options for the prompt.

Enter current password for root (enter for none): Just press the Enter
Set root password? [Y/n]: Y
New password: Enter your password
Re-enter new password: Repeat your password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

Restart the database server for the changes to take effect.

$ sudo systemctl restart mariadb

Login to MariDB shell using the following command:

$ sudo  mysql -u root -p

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE wordpress_db;
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'PaSSw0rd';
MariaDB [(none)]> GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 5: Download WordPress on AlmaLinux 9

We will now download the latest version of WordPress from the WordPress Official site.

Use the following command to download WordPress:

$ sudo wget https://wordpress.org/latest.zip

Extract file into the folder /var/www/html/ with the following command,

$ sudo unzip latest.zip -d /var/www/html/

Change the permission of the website directory:

$ sudo chown -R apache:apache /var/www/html/wordpress/
$ sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R

Step 6: Configure Apache Web Server for WordPress

Navigate to /etc/httpd/conf.d directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/httpd/conf.d/wordpress.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/wordpress

<Directory /var/www/html/wordpress/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog /var/log/httpd/your-domain.com_error.log
CustomLog /var/log/httpd/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Restart the Apache web server.

$ sudo systemctl restart httpd

Step 7: Access WordPress Web Installer

Open your browser type your domain e.g http://your-domain.com  and click on the Let's go! button to complete the required steps:

Provide the requested database information and click on the Submit button:

Start WordPress Installation by clicking on the Run the installation button:

Provide the requested information and click on the Install WordPress button:

Once the WordPress is installed, enter your administrator user, password and click on the Log In button:

You will get the dashboard in the following screen:

Comments and Conclusion

That’s it. You have successfully installed WordPress CMS (Content Management System) on AlmaLinux 9 OS.

If you have any questions please leave a comment below.

How to Install Drupal 9 on Ubuntu 22.04

Drupal is an open-source and popular content management tool that is the foundation of many websites across the internet. It has great standard features, like easy content authoring, reliable performance, and excellent security. Flexibility and modularity are some of the core principles that set it apart from the rest.

In this tutorial, we will show you how to install Drupal 9 on your Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

You can install Apache via apt package manager by executing the following command.

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3170 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 3174 (apache2)
      Tasks: 12 (limit: 2200)
     Memory: 246.8M
        CPU: 18.104s
     CGroup: /system.slice/apache2.service
             ├─3174 /usr/sbin/apache2 -k start
             ├─3175 /usr/sbin/apache2 -k start
             ├─3176 /usr/sbin/apache2 -k start

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default Apache2 Page, as seen below.

Step 3: Install PHP and PHP extensions for Drupal 9

By default, Ubuntu 22.04 comes with PHP version 8.1.  You can install PHP and other supporting packages using the following command:

$ sudo apt install php libapache2-mod-php php-dev php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml

Verify if PHP is installed.

php -v
Output:
PHP 8.1.6 (cli) (built: May 17 2022 16:46:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies

Step 4: Install MySQL and create a database

You can install MySQL with the following command:

$ sudo apt install mysql-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mysql
$ systemctl enable mysql

Verify the status of the MySQL service using systemctl status command:

$ sudo systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
    Process: 832 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1235 (mysqld)
     Status: "Server is operational"
      Tasks: 46 (limit: 2200)
     Memory: 582.6M
        CPU: 1min 11.087s
     CGroup: /system.slice/mysql.service
             └─1235 /usr/sbin/mysqld

Once the database server is installed, log into the MariaDB prompt:

$ sudo  mysql -u root

To create a database, database user, and grant all privileges to the database user run the following commands:

mysql> CREATE DATABASE drupal;
mysql> CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'Drupal_Passw0rd!';
mysql> GRANT ALL ON drupal.* TO 'drupal_user'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Step 5: Download Drupal 9

We will now download Drupal 9 from the Drupal Official site.

Use the following command to download Drupal 9:

$ sudo wget https://ftp.drupal.org/files/projects/drupal-9.3.13.zip

Extract file into the folder /var/www/html/ with the following command:

$ sudo apt -y install unzip 
$ sudo unzip drupal-9.3.13.zip -d /var/www/html/

To make things simpler, rename the extracted directory drupal-9.3.13 to just drupal:

$ sudo mv /var/www/html/drupal-9.3.13/ /var/www/html/drupal/

Enable permission for the Apache webserver user to access the files,

$ sudo chown -R www-data:www-data /var/www/html/drupal/

Step 6: Configure Apache Web Server for Drupal 9

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/apache2/sites-available/drupal.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/drupal

<Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the Drupal 9 virtual host:

$ sudo a2ensite drupal.conf

After that, restart the Apache web server.

$ sudo systemctl restart apache2

Step 7: Access Drupal 9 Web Installer

Open your browser type your domain e.g http://your-domain.com  and complete the required steps to finish the installation.

Choose your preferred language and hit Save and continue, you will get the following screen:

Choose Standard and hit Save and continue. You will get the following screen:

Fill in your database settings and hit Save and continue.

Fill in some basic information about your site and then hit Save and continue. You will get the dashboard in the following screen:

Installation of Drupal has been completed. Now revert the permissions for the settings.php file:

$ sudo chmod 644 /var/www/html/drupal/sites/default/settings.php

Comments and Conclusion

That’s it. You have successfully installed Drupal 9 on Ubuntu 22.04

If you have any questions please leave a comment below.

How to Install Joomla 4 on Ubuntu 22.04

Joomla is a free, open source and one of the most popular Content Management System (CMS) around the world which allow the users to create or build their own website and applications.

It is built on PHP and stores its data on an SQL-based database engine on the backend such as MySQL/MariaDB.

In this tutorial, we will show you how to install Joomla 4 on your Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

You can install Apache via apt package manager by executing the following command.

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-04-26 15:18:33 UTC; 1min 31s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 13521 (apache2)
Tasks: 55 (limit: 2200)
Memory: 4.8M
CPU: 148ms
CGroup: /system.slice/apache2.service
├─13521 /usr/sbin/apache2 -k start
├─13523 /usr/sbin/apache2 -k start
└─13524 /usr/sbin/apache2 -k start

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default Apache2 Page, as seen below.

Step 3: Install PHP and PHP extensions for Joomla 4

You can install PHP 8.1 and other supporting packages using the following command:

$ sudo apt install php libapache2-mod-php php-dev php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml

Verify if PHP is installed.

php -v
Output:
PHP 8.1.2 (cli) (built: Apr 7 2022 17:46:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

You can install MariaDB with the following command:

$ sudo apt install mariadb-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mariadb
$ systemctl enable mariadb

Verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.6.7 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running)
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 27074 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 27075 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 27077 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && >
Process: 27117 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 27119 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 27106 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 7 (limit: 2200)
Memory: 57.0M
CPU: 880ms
CGroup: /system.slice/mariadb.service
└─27106 /usr/sbin/mariadbd

Once the database server is installed, log into the MariaDB prompt:

$ sudo  mysql -u root

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE joomla_db;
MariaDB [(none)]> CREATE USER 'joomla_user'@'localhost' IDENTIFIED BY 'Password';
MariaDB [(none)]> GRANT ALL ON joomla_db.* TO 'joomla_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 5: Download Joomla 4

We will now download the latest version of Joomla from the Official site.

Use the following command to download Joomla 4:

$ sudo wget https://downloads.joomla.org/cms/joomla4/4-1-2/Joomla_4-1-2-Stable-Full_Package.zip

Extract file into the folder /var/www/html/joomla/ with the following command,

$ sudo apt -y install unzip 
$ sudo unzip Joomla_4-1-2-Stable-Full_Package.zip -d /var/www/html/joomla

Enable permission for the Apache webserver user to access the files,

$ sudo chown -R www-data:www-data /var/www/html/joomla/

Step 6: Configure Apache Web Server for Joomla 4

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/apache2/sites-available/joomla.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/joomla

<Directory /var/www/html/joomla/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the Joomla virtual host:

$ sudo a2ensite joomla.conf

Restart the Apache web server.

$ sudo systemctl restart apache2

Step 7: Access Joomla 4 Web Installer

Open your browser type your domain e.g http://your-domain.com  and complete the required steps to finish the installation.

Once the Joomla has been installed, you will get the following screen:

Click on the Open Administrator. You will get the login screen:

Enter your Joomla admin user, password and click on the Log in. You will get the dashboard in the following screen:

Comments and Conclusion

That’s it. You have successfully installed Joomla 4 CMS (Content Management system) on Ubuntu 22.04

If you have any questions please leave a comment below.