Cloudflare Tunnel on Ubuntu 24.04

How to Configure Cloudflare Tunnel on Ubuntu 24.04

Cloudflare Tunnels is a service offered by Cloudflare that allows you to securely expose web services running on your local machine or private network to the internet without needing to open ports, set up firewalls, or use a public IP address.

It creates a secure, encrypted tunnel between your origin server and Cloudflare’s network, enabling access to your applications from anywhere.

In this tutorial we will show you how to configure Cloudflare Tunnel on Ubuntu 24.04.

Step 1: Install and Configure Cloudflared

To create and manage tunnels, you will need to install and authenticate cloudflared on your server.

You can install cloudflared with the following command:

# wget -q wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
# dpkg -i cloudflared-linux-amd64.deb

After installing cloudflared, you need to authenticate it with your Cloudflare account:

# cloudflared tunnel login

You will get the following message:

Please open the following URL and log in with your Cloudflare account:
https://dash.cloudflare.com/argotunnel?aud=&callback=https%3A%2F%2Flogin.cloudflareaccess.org%2F94jJEwKkBV3dOOKv5oPBEj-B9lWITbj_Gk_9sVN1wnw%3D
Leave cloudflared running to download the cert automatically.

Copy the URL and log in to your Cloudflare account. Once you logged in you will get the following message:

Click on the Authorize button to authorize the tunnel. Cloudflare will download a certificate file to authenticate cloudflared with Cloudflare’s network.

You have successfully logged in.
If you wish to copy your credentials to a server, they have been saved to:
/root/.cloudflared/cert.pem

Once authorization is completed successfully, your cert.pem will be download to the default directory.

Step 2: Create a Cloudflare Tunnel

Now, you are ready to create a Cloudflare Tunnel that will connect cloudflared to Cloudflare’s edge. Running the following command will create a Tunnel:

# cloudflared tunnel create yourtunnel

Note: Replace yourtunnel with a name of your choice.

Next, you need to configure the tunnel to point to your local web server. The configuration file contains keys and values, which is written in YAML syntax.

# nano /root/.cloudflared/config.yml

You have to include the correct tunnel ID and credentials file gotten from the tunnel creation command.

tunnel: b8294c45-9cd1-40fe-b8f1-519da5d8dfd9
credentials-file: /root/.cloudflared/b8294c45-9cd1-40fe-b8f1-519da5d8dfd9.json
ingress:
- hostname: test.yourdomain.com
service: http://localhost:80
- service: http_status:404

Next, you have to configure your DNS settings on your Cloudflare account by adding a CNAME record.

Also, you can use this command will generate a CNAME record that points to the subdomain of a specific Tunnel.

# tunnel route dns b8294c45-9cd1-40fe-b8f1-519da5d8dfd9 test.yourdomain.com

Step 3: Start and Manage the Cloudflare Tunnel

By default, the tunnel expects to find the configuration file in the default directory, /root/.cloudflared/config.yml but to run tunnel as a service, you might need to move the config.yml file to the /etc/cloudflared/ directory.

# mkdir /etc/cloudflared/
# mv /root/.cloudflared/config.yml /etc/cloudflared/

Then, you have to install the tunnel as a service:

# cloudflared service install

Now, we can start and enable the cloudflared service so that it runs in the background and starts automatically upon server boot.

# systemctl start cloudflared
# systemctl enable cloudflared

You can verify the status of the cloudflared service using the systemctl status command:

# systemctl status cloudflared
Output:
● cloudflared.service - cloudflared
Loaded: loaded (/etc/systemd/system/cloudflared.service; enabled; preset: enabled)
Active: active (running)
Main PID: 2316 (cloudflared)
Tasks: 7 (limit: 2218)
Memory: 14.0M (peak: 16.1M)
CPU: 9.227s
CGroup: /system.slice/cloudflared.service
└─2316 /usr/bin/cloudflared --no-autoupdate --config /etc/cloudflared/config.yml tunnel run

Step 4: Add more services (optional)

If we have multiple services using the same tunnel, you have to create separate CNAME entries for each hostname.

# cloudflared tunnel route dns <UUID or NAME> test2.yourdomain.com

Then Add another ingress point to the config:

ingress:
- hostname: test.yourdomain.com
service: http://localhost:80
- hostname: test2.yourdomain.com
service: http://localhost:8080
- service: http_status:404

Comments and Conclusion

That’s it. You have successfully Configure Cloudflare tunnel on Ubuntu 24.04

For additional help or useful information, we recommend you to check  the official Cloudflare Tunnel documentation.

If you have any questions please leave a comment below.

r

How to Install PHP 8.4 on Ubuntu 24.04

PHP (Hypertext Preprocessor) is a widely-used, open-source, server-side scripting language designed for web development. It is especially suited for creating dynamic web pages and applications.

In this tutorial, we will show you how to install PHP 8.4 on a Ubuntu 24.04 OS.

Update Operating System

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

# apt update && apt upgrade

Add PHP Repository

By default, PHP 8.4 is not included in the Ubuntu 24.04 default repository.  So you will need to add Ondrej Sury PPA into your system.

First, install the required packages using the following command:

# apt-get install ca-certificates apt-transport-https software-properties-common

Once all the packages are installed, add this PPA using the following command:

# add-apt-repository ppa:ondrej/php

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

# apt-get update

Install PHP 8.4

Now, you can install the PHP 8.4 using the following command:

# apt-get install php8.4

Once the PHP is installed, you can check the PHP version on your system with the following command:

# php8.4 --version

Output:

# PHP 8.4.1 (cli) (built: Nov 21 2024 14:54:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.1, Copyright (c), by Zend Technologies

Install PHP 8.4 for Apache

To install PHP as an Apache module, execute:

# apt install libapache2-mod-php8.4

Then, restart Apache to integrate the new PHP module:

# systemctl restart apache2

To verify that PHP is working with the Apache web server, you can create a test PHP file:

echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php

Then open your web browser and type http://your-IP-address/info.php and you should see the PHP information page.

Install PHP 8.4 FPM for Nginx

For the Nginx web server, you need to install the FPM service, you can install it using the following command:

# apt install php8.4-fpm

Once the installation has been completed, you can confirm that the PHP-FPM service has been installed correctly with the following command:

# systemctl status php8.4-fpm

Output:

● php8.4-fpm.service - The PHP 8.4 FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php8.4-fpm.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:php-fpm8.4(8)
    Process: 11741 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.4/fpm/pool.d/www.conf 84 (code=exited, status=0/SUCCESS)
   Main PID: 11737 (php-fpm8.4)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00req/sec"
      Tasks: 3 (limit: 2218)
     Memory: 8.0M (peak: 9.0M)
        CPU: 116ms
     CGroup: /system.slice/php8.4-fpm.service
             ├─11737 "php-fpm: master process (/etc/php/8.4/fpm/php-fpm.conf)"
             ├─11739 "php-fpm: pool www"
             └─11740 "php-fpm: pool www"

Test PHP and PHP-FPM

To configure Nginx to use PHP-FPM, you need to edit the default Nginx configuration file:

# nano /etc/nginx/sites-available/default

Add the following configurations to the file.

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
}

Check Nginx syntax:

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

Then create a test PHP file similar to the Apache setup:

echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Then open your web browser and type http://your-IP-address/info.php and you should see the PHP information page.

Install PHP Extension

Installing PHP extensions are simple with the below-mentioned syntax:

# sudo apt install php8.4-[extension]

Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces:

# apt install php8.4-mysql php8.4-imap php8.4-ldap php8.4-xml php8.4-curl php8.4-mbstring php8.4-zip

To check loaded PHP modules use the command:

# php8.4 -m

Example Output:

[PHP Modules]
..............
imap
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
..............

[Zend Modules]
Zend OPcache

Running PHP 8.4 with Other Versions

Instead of removing old PHP versions, it is also possible to run multiple PHP versions side-by-side.

The update-alternatives command provides an easy way to switch between PHP versions for PHP CLI.

# update-alternatives --config php

This brings up a prompt to interactively select the alternative PHP binary path that php points to.

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php.default   100       auto mode
  1            /usr/bin/php.default   100       manual mode
  2            /usr/bin/php8.3        83        manual mode
  3            /usr/bin/php8.4        84        manual mode

To set the path without the interactive prompt:

# update-alternatives --set php /usr/bin/php8.4

Comments and Conclusion

In the tutorial, you have learned how to install PHP 8.4 on Ubuntu 24.04.

For additional help or useful information, we recommend you to check the official PHP 8.4 documentation.

If you have any questions please leave a comment below.

How to Install Odoo 18 on Ubuntu 24.04

Odoo 18 is an open-source suite of business applications that provides a complete ERP (Enterprise Resource Planning) solution for organizations of various sizes. It offers a wide range of integrated tools and modules to help manage all aspects of a business, such as finance, sales, inventory, human resources, and more.

The open-source community edition is free, making it accessible to small businesses and developers. The enterprise edition, on the other hand, offers additional features, services, and support.

Odoo is highly customizable. Businesses can tailor modules to meet their specific needs, create custom workflows, or build entirely new apps using Odoo’s development framework.

In summary, Odoo is a versatile business management software that can streamline operations and provide real-time insights, making it an ideal solution for companies looking to optimize their business processes.

In this tutorial, we will show you how to install Odoo 18 on a Ubuntu 24.04 OS.

Step 1: Update Operating System

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

# apt update && apt upgrade

Then install all the required packages for the Odoo 18 setup on the Ubuntu 24.04 OS.

# apt install python3-minimal python3-dev python3-pip python3-venv python3-setuptools build-essential libzip-dev libxslt1-dev libldap2-dev python3-wheel libsasl2-dev node-less libjpeg-dev xfonts-utils libpq-dev libffi-dev fontconfig git wget

Step 2: Install PostgreSQL

Odoo uses PostgreSQL as a database backend, so you will need to install PostgreSQL on your server.

Follow these steps to install and configure PostgreSQL server:

# apt-get install postgresql

After the successful installation, start the PostgreSQL service and enable it to start after the system reboot:

# systemctl start postgresql
# systemctl enable postgresql

Verify that is active and running on your server:

# systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited)
   Main PID: 19754 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Now create an Odoo user in PostgreSQL:

# su - postgres -c "createuser -s odoo" 

This will add a new role odoo in the PostgreSQL server.

Step 3: Install Node.js

To install Node.js and npm on your Ubuntu 24.04 OS use the following command:

# apt install nodejs npm

Also, install the following module to enable RTL support:

# npm install -g rtlcss

Step 4: Installation of wkhtmltopdf

To generate PDF reports successfully, wkhtmltopdf is necessary. PDF reports are a crucial component of any organization.

First install the xfonts dependency before installing wkhtmltopdf:

# apt-get install xfonts-75dpi xfonts-base

Now download and install wkhtmltopdf using the following commands:

# wget  http://security.ubuntu.com/ubuntu/pool/universe/w/wkhtmltopdf/wkhtmltopdf_0.12.6-2build2_amd64.deb
# dpkg -i wkhtmltopdf_0.12.6-2build2_amd64.deb

Verify if the wkhtmltopdf installation is successful by checking the version:

# wkhtmltopdf --version
wkhtmltopdf 0.12.6

Step 5: Create an Odoo User

Create a new system user for managing the Odoo processes on the Odoo server.

# adduser --system --group --home=/opt/odoo --shell=/bin/bash odoo

Step 6: Install Odoo 18

Switch to the user that you have created before to avoid encountering issues related to access rights.

# su - odoo

Now, download the Odoo 17 source code from the git repository and install it:

# git clone https://www.github.com/odoo/odoo --depth 1 --branch 18.0 /opt/odoo/odoo

Next run the following command to generate a new Python virtual environment.

# python3 -m venv odoo-env

Activate the virtual environment with the following command:

# source odoo-env/bin/activate

Then install the required Python packages:

(odoo-env) $ pip3 install wheel
(odoo-env) $ pip3 install -r odoo/requirements.txt

After completing the process of installing all requirements to deactivate the virtual environment run the following command:

(odoo-env) $ deactivate

Execute the following command to create a directory for custom addons:

# mkdir /opt/odoo/custom-addons

Next exit from the Odoo user:

# exit

Create an Odoo log directory and provide it the required write permissions.

# mkdir /var/log/odoo18
# chown odoo:odoo /var/log/odoo18

Step 7: Create Odoo Configuration File

Create the Odoo configuration file.

# nano /etc/odoo.conf

Then paste the following configuration into it.

[options]
admin_passwd = Strong_admin_Password
db_host = False
db_port = False
db_user = odoo
db_password = False
logfile = /var/log/odoo18/odoo-server.log
addons_path = /opt/odoo/odoo/addons,/opt/odoo/custom-addons
xmlrpc_port = 8069

Remember to update the value of the “Strong_admin_Password” key above with a more secure password.

Step 8: Create a Systemd Service File

Create a systemd service file to manage the Odoo service:

# nano /etc/systemd/system/odoo.service

Paste the following content into the odoo.service file:

[Unit]
Description=Odoo
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-env/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Reload system daemon and start the service:

# systemctl daemon-reload
# systemctl start odoo
# systemctl enable odoo

To confirm everything is working normally, check the status of service:

# systemctl status odoo

Output:

● odoo.service - Odoo
     Loaded: loaded (/etc/systemd/system/odoo.service; enabled; preset: enabled)
     Active: active (running)
   Main PID: 21764 (python3)
      Tasks: 4 (limit: 2218)
     Memory: 73.3M (peak: 73.5M)
        CPU: 973ms
     CGroup: /system.slice/odoo.service
             └─21764 /opt/odoo/odoo-env/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf

Step 9: Access Odoo 18 server

Open your web browser and type http://your-IP-address:8069 and you will see the following screen:

Comments and Conclusion

That’s it. You have successfully installed Community version of Odoo 18 on Ubuntu 24.04.

For additional help or useful information, we recommend you to check  the official Odoo 18 documentation.

If you have any questions please leave a comment below.

How to Install Git on Ubuntu 24.04

Git is a distributed version control system (VCS) used for tracking changes in source code during software development. It allows multiple developers to work on a project simultaneously, making it easier to collaborate, manage, and track changes.

It is widely used in software development, from small personal projects to large-scale enterprise applications. Git is the backbone of many collaborative development workflows, enabling teams to work together efficiently and effectively.

In this tutorial, we will show you how to install Git on a Ubuntu 24.04 OS.

Method 1: Install Git with default package manager APT

Installing Git with a package manager like apt offers you ease of installation; it also allows you easily manage and update Git. However, the version in the default repository is often not the latest release.

The version of Git you get with this method may not be the latest version. This is because Ubuntu prioritizes stability and thorough testing over cutting-edge updates to ensure that software in the official repositories is reliable and secure for users.

Ubuntu 24.04 should have git installed by default. Run the following command to check if you have git installed:

# git --version

If Git is already installed, the version should be displayed:

git version 2.43.0

In order to have the latest LTS version, you will need to add a PPA repository using the following command:

# add-apt-repository ppa:git-core/ppa 

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

# apt update & apt upgrade

Then install Git:

# apt install git

Verify the installation and display the Git version:

git --version

Output:

git version 2.46.0

Method 2: Install Git from source code

If you want to install a different version of Git you can use the following method to install Git.

First, you need to install some packages that are required for the successful installation and functioning of Git.

# apt install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential

Once the packages have been installed, you can go to download Git from the download page.

In our case we will install 2.46.0 version.

# wget https://www.kernel.org/pub/software/scm/git/git-2.46.0.tar.gz

Run the following command to extract the downloaded archive:

# tar -xvf git-2.46.0.tar.gz

Navigate to the extracted directory with the following command:

# cd git-2.46.0

Run the following commands to compile the Git source code and install Git and also restart the bash shell to save the changes:

# make prefix=/usr/local all 
# make prefix=/usr/local install 
# exec bash

To verify the installation, use the following command:

git --version

Output:

git version 2.46.0

Basic configuration

Once Git is installed, you will need to configure it with the Git config command:

git config --global user.name "Linux Tuto" 
git config --global user.email "your_email@example.com" 

Verify the changes:

# git config --list
user.name=Linux Tuto
user.email=your_email@example.com

Comments and Conclusion

That’s it. You have successfully installed Git on Ubuntu 24.04.

For additional help or useful information, we recommend you to check  the official Git documentation.

If you have any questions please leave a comment below.

How to Install Drupal on Ubuntu 24.04

Drupal is an open-source content management system (CMS) used for building and managing websites and web applications. It is highly flexible and customizable, making it suitable for a wide range of web projects, from simple blogs to complex enterprise websites.

It is used by a wide range of organizations, including educational institutions, non-profits, businesses, and government agencies, to build websites that require robust content management, high security, and flexibility.

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

Step 1: Update Operating System

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

# apt update && apt upgrade -y

Step 2: Install Nginx webserver

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

# apt install nginx

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

# systemctl start nginx
# systemctl enable nginx

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

# systemctl status nginx

Output:

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
   Main PID: 10412 (nginx)
      Tasks: 2 (limit: 2218)
     Memory: 1.7M (peak: 1.9M)
        CPU: 23ms
     CGroup: /system.slice/nginx.service
             ├─10412 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─10413 "nginx: worker process"

Step 3: Install PHP and PHP extensions for Drupal

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

# apt install php php-{opcache,gd,curl,mysqlnd,intl,json,ldap,mbstring,mysqlnd,xml,zip}

Verify if PHP is installed.

php -v
Output:
PHP 8.3.6 (cli) (built: Jun 13 2024 15:23:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# 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:

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running)
    Process: 24565 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 24574 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2218)
     Memory: 362.8M (peak: 379.1M)
        CPU: 1.160s
     CGroup: /system.slice/mysql.service
             └─24574 /usr/sbin/mysqld

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

# 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 MySQL shell.

# mysql -u root -p

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

mysql> CREATE DATABASE drupaldb;
mysql> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'Str0ngP@ss';
mysql> GRANT ALL PRIVILEGES ON drupaldb. * TO 'drupaluser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download Drupal

The latest version of Drupal is available to download from their website. You can download it with the following command:

# wget https://ftp.drupal.org/files/projects/drupal-11.0.0.zip

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

# unzip drupal-11.0.0.zip -d /var/www/

Rename it to make it simpler:

# mv /var/www/drupal-11.0.0/ /var/www/drupal

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

# chown -R www-data:www-data /var/www/drupal/

Step 6: Configure Nginx for Drupal

Create a new Nginx virtual host configuration file:

# nano /etc/nginx/conf.d/drupal.conf

Paste the content as shown below:

server {
  listen 80;
  server_name your-domain.com www.your-domain.com;
  root /var/www/drupal;
  index index.php index.html;
  charset utf-8;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  location ~ .php$ {
    fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

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:

# systemctl restart nginx

Step 7: Access Drupal Web Interface

Open your web browser and type the URL https://your-domain.com. You should see the Drupal installation page.

Choose your preferred language and hit Save and continue. You will get the following screen:

Choose Standard and hit Save and continue.

Fill in your database settings and hit Save and continue.

Then 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:

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

Comments and Conclusion

That’s it. You have successfully installed Drupal on Ubuntu 24.04 OS.

For additional help or useful information, we recommend you to check  the official Drupal documentation.

If you have any questions please leave a comment below.

How to Install Magento 2.4.7 on Ubuntu 24.04

Magento is an open-source e-commerce platform that provides online merchants with a flexible shopping cart system, as well as control over the look, content, and functionality of their online stores. It also has a large community of developers and users who contribute to its ongoing development and provide support through forums, documentation, and other resources.

Magento comes in two main editions: Magento Open Source (formerly known as Magento Community Edition) and Magento Commerce (formerly known as Magento Enterprise Edition). The Open Source edition is free to use and provides basic e-commerce functionality, while the Commerce edition is a paid version that includes more advanced features such as customer segmentation, targeted promotions, and advanced marketing tools.

In this tutorial we will show you how to install the Open Source version of Magento 2.4.7 on Ubuntu 24.04 OS.

Before starting the installation, you can check the system requirement for installing Magento 2.4.7.

Step 1: Update Operating System

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

# apt update && apt upgrade

Step 2: Install Apache web server

To install Apache web server, run the following command:

# apt install apache2

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

# systemctl start apache2
# systemctl enable apache2

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

# systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 22413 (apache2)
      Tasks: 6 (limit: 2130)
     Memory: 16.8M (peak: 17.0M)
        CPU: 658ms
     CGroup: /system.slice/apache2.service
             ├─22413 /usr/sbin/apache2 -k start
             ├─22468 /usr/sbin/apache2 -k start
             ├─22469 /usr/sbin/apache2 -k start
             ├─22470 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions

Magento 2.4.7 comes with support for the latest PHP 8.3, while PHP 8.2 remains fully supported. By default, PHP 8.3 is included in the Ubuntu 24.04 default repository.

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

# apt install php php-exif php-bz2 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.3.0-1ubuntu1 (cli) (built: Jan 19 2024 14:00:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0-1ubuntu1, Copyright (c), by Zend Technologies

Update php.ini file

Now it’s time to increase values in the php.ini file.

Open php.ini file:

# nano /etc/php/8.3/apache2/php.ini

Change the following data:

short_open_tag = On
memory_limit = 512M
upload_max_filesize = 128M
max_execution_time = 3600

Then save this php.ini file.

After that, you should restart the Apache web server for the configuration to take effect:

# systemctl restart apache2

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# apt install mysql-server

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

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running)
    Process: 2907 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2919 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 2130)
     Memory: 362.8M (peak: 379.2M)
        CPU: 1.737s
     CGroup: /system.slice/mysql.service
             └─2919 /usr/sbin/mysqld

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

# 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 MySQL shell.

# mysql -u root -p

Once you are logged in to your database server to create a database, database user, and grant all privileges to the database user run the following commands:

mysql> CREATE DATABASE magentodb;
mysql> CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'Str0ngPa$$w0rd';
mysql> GRANT ALL ON magentodb.* TO 'magentouser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Step 5: Installing Elasticsearch

Starting Magento 2.4, all installations must be configured to use Elasticsearch as the catalog search engine.

Import the Elasticsearch GPG key:

# wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

Add the Elasticsearch repository:

# echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list

Update the apt package manager and install Elasticsearch:

# apt update && apt install elasticsearch

Then start and enable the service:

# systemctl start elasticsearch
# systemctl enable elasticsearch

Open the elasticsearch.yml file:

# nano  /etc/elasticsearch/elasticsearch.yml

Then uncomment the lines and update the values:

node.name: "ubuntu"
cluster.name: magento 2.4.7
network.host: 127.0.0.1
http.port: 9200
xpack.security.enabled: false

After that, you should restart elasticsearch service for the configuration to take effect:

# systemctl restart elasticsearch

To verify that Elasticsearch is running correctly, you will use the curl command:

# curl -X GET "localhost:9200/"

If Elasticsearch is working properly, the result should be like this:

{
  "name" : "ubuntu",
  "cluster_name" : "magento 2.4.7",
  "cluster_uuid" : "nKzTibHRT_ahq6lCsWk6Ew",
  "version" : {
    "number" : "8.13.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "9287f29bba5e270bd51d557b8daccb7d118ba247",
    "build_date" : "2024-03-29T10:05:29.787251984Z",
    "build_snapshot" : false,
    "lucene_version" : "9.10.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Step 6: Install Composer

To download Composer, run the following command:

# curl -sS https://getcomposer.org/installer | php

Next, move the composer file to the /usr/local/bin path:

# mv composer.phar  /usr/local/bin/composer
# chmod +x   /usr/local/bin/composer

Verify the Composer version installed:

# composer --version

Output:
Composer version 2.7.2 2024-03-11 17:12:18

Step 7: Install Magento 2.4.7

For most situation it is recommended to install Magento using the Marketplace by creating access key.

To get the access keys, you should create an account in the Magento marketplace.

Then for generating access keys go to:

My profile > Marketplace > My products > Access Keys

Once access keys are generated run the following  command to download Magento 2.4.7:

# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.7 /var/www/magento2

Username : Your Public Key
Password : Your Private Key

Navigate to the Magento directory:

# cd /var/www/magento2

Chmod cache and static content folder:

# find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +

Change the ownership of the magento2 directory to the webserver user and also the permissions:

# chown -R www-data:www-data /var/www/magento2
# chmod -R 755 /var/www/magento2

Now, install Magento using the composer command, type:

# bin/magento setup:install \
--base-url=http://your-domain.com \
--db-host=localhost \
--db-name=magentodb \
--db-user=magentouser \
--db-password='Str0ngPa$$w0rd' \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@your-domain.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

After the installation process you will see the admin link for your Magento site.

[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_nuqh2y
Nothing to import.

Step 8: Configure Apache for Magento 2.4.7

Run the command below to create a new VirtualHost file in the /etc/apache2/sites-available/ directory:

# nano /etc/apache2/sites-available/magento2.conf

Paste the content as shown below:

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

    <Directory /var/www/magento2/> 
        AllowOverride 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.

Next run the following command to enable rewrite module:

# a2enmod rewrite

To enable this site run the command:

# a2ensite magento2.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 9: Access your Magento 2.4.7 Application

Open your browser and type your domain http://your-domain.com

Comments and Conclusion

That’s it. You have successfully installed Open Source version of Magento 2.4.7 on Ubuntu 24.04.

For additional help or useful information, we recommend you to check  the official Magento documentation.

If you have any questions please leave a comment below.

How to Install Docker on Ubuntu 24.04

Docker is a platform designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all parts it needs, such as libraries and other dependencies, and ship it all out as one package. This ensures that the application runs reliably when moved from one computing environment to another.

Docker provides tools and a platform to manage these containers efficiently, allowing developers to focus on writing code without worrying about the environment in which their code will run.

In this tutorial, we will show you how to install Docker on Ubuntu 24.04 OS.

Step 1: Update Operating System

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

# apt update && apt upgrade

Step 2: Install Dependencies

Install the required packages to allow Ubuntu 24.04 to access the Docker repositories over HTTPS:

# apt install apt-transport-https ca-certificates curl software-properties-common

Step3: Add GPG Key

Add the Docker repository GPG key with the following command:

# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 4: Add Docker Repository

To be able to install Docker on Ubuntu 24.04 you need to add the Docker repository to APT sources:

# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Step 5: Install Docker

Once the repository has been added to the system, you are now ready to install Docker with the following command:

# apt install docker-ce

You can verify the installed version of Docker with the following command:

# docker --version

Output:

Docker version 26.0.0, build 2ae903e

Check the status of the service:

# systemctl status docker

Example output:

● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: active (running)
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 7047 (dockerd)
      Tasks: 7
     Memory: 27.4M (peak: 27.9M)
        CPU: 396ms
     CGroup: /system.slice/docker.service
             └─7047 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

By default, Docker should start on boot. But if it doesn’t, you can enable it to start automatically at the next boot with the following command:

#systemctl enable docker

Step 6: Test Docker

Run a test Docker container to ensure everything is working correctly:

# docker run hello-world

This command downloads a test image from the Docker Hub repository and runs it in a container:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6
Status: Downloaded newer image for hello-world:latest

Step 7: Using the Docker Command

To see only the active containers, run:

# docker ps

To list all containers, including the inactive ones, add the -a flag:

# docker ps -a

Start a stopped container the syntax is:

# docker start [container-ID | container-name]

Stop a running container the syntax is:

# docker stop [container-ID | container-name]

Remove an unnecessary container the syntax is:

# docker rm [container-ID | container-name]

To view all of the available subcommands use the following command:

# docker

Output:

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        Block until one or more containers stop, then print their exit codes

Step 8: Run Docker without Sudo

If we want to use Docker without root privileges, you need to run the following command:

# usermod -aG docker $User

Note: “$USER” is just a place holder that needs to be replaced with your username.

After that, restart the system, and the changes will be applied.

Comments and Conclusion

Congratulations! You have successfully installed Docker on your Ubuntu 24.04 OS.

Also, you can check our tutorial how to install Portainer on Ubuntu OS. Portainer is a container management tool that provides a web-based graphical user interface (GUI) for managing Docker containers, images, networks, and volumes.

For additional help or useful information, we recommend you to check the official Docker documentation.

If you have any questions please leave a comment below.

How to Install Jupyter Notebook on Debian 12

Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. It’s widely used in various fields such as data science, machine learning, scientific computing, and education.

The term “Jupyter” is derived from the combination of three programming languages: Julia, Python, and R. These were the first languages supported by the Jupyter project, but now it supports many other programming languages through its interactive computing protocol.

In this tutorial, we will show you how to install Jupyter Notebook on Debian 12 OS with Apache web server

Step 1: Update Operating System

Update your Debian 12 operating system to the latest version with the following command:

# apt update && apt upgrade -y

Step 2: Install Pip on Debian 12

Python comes already installed by default on Debian 12. You can verify it by checking its version:

# python3 -V
Output:
Python 3.11.2

If it doesn’t, install Python with the following command:

# apt install python3

Then use the following command to install pip and venv on Debian 12:

# apt install python3-venv python3-pip

Verify your pip installation by checking its version:

# pip3 --version
Output:
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)

Step 3: Install Jupyter Notebook Using Virtualenv

First, create a directory and switch to it with the commands below:

# mkdir /var/www/notebook 
# cd /var/www/notebook

Before you install Jupyter Notebook, you first need to create a Python virtual environment.

# python3 -m venv notebook_env

Next, activate the virtual environment with the following command:

# source notebook_env/bin/activate

Next, install Jupyter Notebook using the following command:

(notebook_env) # pip install jupyter

Once the installation is completed, run the Jupyter Notebook with the following command:

(notebook_env) # jupyter notebook --allow-root

Press the CTRL+C to stop the Jupyter Notebook.

Step 4: Generate Jupyter Notebook Password

First, generate a Jupyter Notebook configuration file with the following command:

(notebook_env) # jupyter notebook --generate-config

You should see the following output:

Writing default config to: /root/.jupyter/jupyter_notebook_config.py

Then run the following command and enter your preferred password:

(notebook_env) # jupyter notebook password

Set a password as shown below:

Enter password: 
Verify password: 
[JupyterPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_server_config.json

This can be used to reset a lost password or if you believe your credentials have been leaked and desire to change your password.

You can prepare a hashed password manually, using the function jupyter_server.auth.passwd():

>>> jupyter_server.auth import passwd
>>> passwd()
Enter password:
Verify password:
'argon2:$argon2id$v=19$m=10240,t=10,p=8$WGqsBZQPacu0FwsczXPlIQ$VXMyCfkJJZETyjdB6aWNSu/t0OrLAVhpkM15wKJYQRU'

Then add the hashed password to your jupyter_notebook_config.py file:

nano /root/.jupyter/jupyter_notebook_config.py
c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$WGqsBZQPacu0FwsczXPlIQ$VXMyCfkJJZETyjdB6aWNSu/t0OrLAVhpkM15wKJYQRU'

Now, deactivate from the Python virtual environment with the following command:

deactivate

Step 5: Create a Systemd service

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

# nano /lib/systemd/system/jupyter.service

Add the following lines:

[Unit]
Description=Jupyter Notebook

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/var/www/notebook/notebook_env/bin/jupyter-notebook --config=/root/.jupyter/jupyter_notebook_config.py --allow-root
User=root
Group=root
WorkingDirectory=/var/www/notebook/notebook_env
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

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

# systemctl daemon-reload

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

# systemctl start jupyter
# systemctl enable jupyter

Edit the configuration file and enable remote access:

nano /root/.jupyter/jupyter_notebook_config.py

Uncoment and change the following line to True:

c.ServerApp.allow_remote_access = True

To implement the changes, you need to restart the jupyter service:

# systemctl restart jupyter

Step 6: Configure Apache as a Reverse Proxy for Jupyter Notebook

Jupyter Notebook is started and running on port 8888.You can install it via apt package manager by executing the following command.

# apt install apache2

You can verify the status of the Apache service using the systemctl status command:

# systemctl status apache2

Next run the following commands to enable necessary modules:

# /usr/sbin/a2enmod proxy
# /usr/sbin/a2enmod proxy_http

Run the commands below to create a new VirtualHost file called jupyter in the /etc/apache2/sites-available/ directory.

# nano /etc/apache2/sites-available/jupyter.conf

Paste the content as shown below:

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

    ProxyPass / http://127.0.0.1:8888/
    ProxyPassReverse / http://127.0.0.1:8888/> 

    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.

Then save and exit the configuration file.

To enable this site run the following command:

# ln -s /etc/apache2/sites-available/jupyter.conf /etc/apache2/sites-enabled/jupyter.conf

To implement the changes, you need to restart the Apache webserver:

# systemctl restart apache2

Step 7: Accessing Jupyter Notebook Web Interface

Open your web browser using the URL http://your-domain.com. You should see the Jupyter login page:

Enter your password and click on the Login button. You should see the dashboard on the following screen:

Comments and Conclusion

That’s it. You have successfully installed Jupyter Notebook on Debian 12.

For additional help or useful information, we recommend you to check  the official Jupyter Notebook documentation.

If you have any questions please leave a comment below.