Magento 2.4.6

How to Install Magento 2.4.6 on Ubuntu 22.04

Magento is an open-source e-commerce platform that allows businesses to create and manage their online stores. It was first released in 2008 and has since become one of the most popular e-commerce platforms in the world.

Magento provides a range of features and tools that help businesses to customize their online store and manage their products, customers, and orders.

Some of the key features of Magento include a robust shopping cart system, customizable product pages, flexible pricing rules, integrated payment and shipping options, and a wide range of extensions and plugins that can be used to enhance the functionality of the platform.

Magento is also known for its scalability, which means it can be used by businesses of all sizes, from small startups to large enterprises.

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

Before starting the installation, you can check the system requirement for installing Magento2:

Step 1: Update Operating System

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

# apt update && sudo apt upgrade -y

Step 2: Install Nginx web server

To install Nginx web server, run the following command:

# apt install nginx

Once installed, Nginx should be running. If it’s not, for whatever reason, start it:

# systemctl start nginx

Then enable it to start on boot time.

# systemctl enable nginx

Step 3: Install PHP and PHP extensions

Magento 2.4.6 comes with support for the latest PHP 8.2, while PHP 8.1 remains fully supported. By default, PHP 8.1 is included in the Ubuntu 22.04 default repository.

You can install PHP 8.1 using the following command:

# apt-get install php php-dev php-fpm 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-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies

Update php.ini file

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

To locate the PHP configuration file run the following command:

# php --ini | grep "Loaded Configuration File"

Output:
Loaded Configuration File:         /etc/php/8.1/cli/php.ini

Open php.ini file:

# nano /etc/php/8.1/cli/php.ini

Change the following data:

file_uploads = On
allow_url_fopen = On
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 nginx for the configuration to take effect:

# systemctl restart nginx

Step 4: Install MySQL 8 and create a database

You can install MySQL 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

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

#  mysql -u root -p

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 'MyPassword';
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

Now open the elasticsearch.yml file

sudo nano  /etc/elasticsearch/elasticsearch.yml

and replace this setting with false:

# Enable security features
xpack.security.enabled: false

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

# systemctl restart elasticsearch.service

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" : "elasticsearch",
  "cluster_uuid" : "KPbFKCVLT9uu-RFxzxH_Bw",
  "version" : {
    "number" : "8.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "2d58d0f136141f03239816a4e360a8d17b6d8f29",
    "build_date" : "2023-02-13T09:35:20.314882762Z",
    "build_snapshot" : false,
    "lucene_version" : "9.4.2",
    "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

Assign execute permission:

# chmod +x   /usr/local/bin/composer

Verify the Composer version installed:

# composer --version

Output:
Composer version 2.5.4 2023-02-15 13:10:06

Step 7: Install Magento 2.4.6

For most situation it is recommended to install Magento using the Marketplace by creating access key.
For generating Access keys go to:

My profile > Marketplace > My products > Access Keys

Run the following  command to download Magento 2.4.6 data:

# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6 /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 Magento 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=MyPassword \
--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_o07lew
Nothing to import.

Step 8: Configure Nginx Web Server for Magento 2.4.6

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

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

Add the following content:

upstream fastcgi_backend {
  server  unix:/run/php/php8.1-fpm.sock;
}

server {

  listen 80;
  server_name your-domain.com www.your-domain.com;
  set $MAGE_ROOT /var/www/magento2;
  include /var/www/magento2/nginx.conf.sample;
}

Save the file and Exit.

Restart the Nginx web server.

# systemctl restart nginx

Step 9: Access your Magento 2.4.6 Application

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

Comments and Conclusion

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

If you have any questions please leave a comment below.

How to Install PyroCMS on Ubuntu 22.04

PyroCMS is a popular open-source content management system (CMS) that is built on top of the Laravel PHP framework. It is a powerful and flexible CMS that can be used to create websites, blogs, and online stores.

In this tutorial, we will guide you through the process of installing PyroCMS on Ubuntu 22.04.

Step 1: Update Operating System

The first step is to ensure that your system is up-to-date. You can do this by running the following command:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Nginx Web Server

PyroCMS requires a web server to run, and we will be using the Nginx web server in this tutorial. To install Nginx, run 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: 64219 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 64220 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 64310 (nginx)
      Tasks: 2 (limit: 2200)
     Memory: 3.3M
        CPU: 181ms
     CGroup: /system.slice/nginx.service
             ├─64310 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─64313 "nginx: worker process"

Step 3: Install PHP and PHP extensions for PyroCMS

PyroCMS requires PHP version 7.4 or later to be installed on your Ubuntu system. By default, Ubuntu 22.04 comes with PHP version 8.1.

To install PHP and the necessary extensions, run the following command:

$ sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear

Once the installation is complete verify if PHP is installed:

php -v
Output:
PHP 8.1.2-1ubuntu2.10 (cli) (built: Jan 16 2023 15:19:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.10, Copyright (c), by Zend Technologies

Step 4: Install Composer dependency manager

Composer is a dependency manager for PHP that is required for installing PyroCMS. To install Composer, run the following commands:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Verify that Composer has been installed successfully by running the following command:

composer --version
Composer version 2.5.4 2023-02-15 13:10:06

Step 5: Install MariaDB database server

PyroCMS requires a database to store content and other information. In this tutorial, we will be using MariaDB, a popular open-source database server.

To install the MariaDB database server, 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.12 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: 60189 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 60190 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 60192 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && >
    Process: 60235 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 60237 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 60221 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2200)
     Memory: 61.0M
        CPU: 541ms
     CGroup: /system.slice/mariadb.service
             └─60221 /usr/sbin/mariadbd

Once the installation is complete, run the following command to secure your MariaDB server:

$ 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

Step 6: Create a New Database for PyroCMS

Once you have installed MariaDB, you’ll need to create a new database and user for PyroCMS to use.

To do this, log in to your MariaDB server using the following command:

$ sudo mysql -u root -p

You will be prompted to enter your root password. Once you have entered your password, you will be taken to the MariaDB prompt.

Run the following commands to create a new database and user:

MariaDB [(none)]> CREATE DATABASE pyrocms;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON pyrocms.* TO 'pyro'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Note: Make sure to replace 'password' with a strong password of your choice.

Step 7: Download and Install PyroCMS

Create a new directory for your PyroCMS installation using the following command:

$ sudo mkdir /var/www/pyrocms

Download the latest stable release of PyroCMS from the command line:

$ cd /var/www/pyrocms
$ sudo composer create-project pyrocms/pyrocms .

Change ownership of the /var/www/pyrocms directory to www-data.

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

Step 8: Configure Nginx for PyroCMS

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

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

Paste the content as shown below:

server {
  listen 80;
  server_name your-domain.com www.your-domain.com;
  root /var/www/pyrocms/public;
  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.1-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:

$ sudo systemctl restart nginx

Step 9: Access PyroCMS Web Interface

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

Follow the on-screen instructions to complete the installation process. Agree to the license agreement and provide all the information like a database connection and creating an admin user.

Then click on the Install button, you should see the following page:

Now, click on Login button, you should see the following page:

Provide your admin credential and click on the Login button, you should see the PyroCMS dashboard in the following page:

Comments and Conclusion

That’s it! You have successfully installed PyroCMS on your Ubuntu 22.04 system. You can now start building your website using PyroCMS.

To access the PyroCMS admin area just append /admin to your site URL.

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

How to Install Vue.js on Ubuntu 22.04

Vue.js is a popular open-source JavaScript framework used for building user interfaces and single-page applications. It was created by Evan You and was first released in February 2014. Vue.js is a progressive framework, meaning it can be adopted incrementally as needed, allowing developers to start small and add more functionality as needed. Vue.js provides a reactive and composable system for building user interfaces, which makes it a popular choice for creating modern web applications.

In this tutorial, we will show you how to install Vue.js on 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:

# apt update && sudo apt upgrade -y

Step 2: Install Node.js

Vue.js is built on top of Node.js, so we need to install it first.

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

We’ll install Node.js version 18.x LTS on our Ubuntu OS.

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

After the repository is added successfully, run the following command to install Node.js:

# apt install nodejs

You can verify the installation by running the following command:

# node --version

You should see the version number of Node.js installed on your system:

v18.14.1

The next step is to update the npm version:

# npm install npm@latest -g

Verify the npm version with the following command:

# npm --version

You should get the following output:

9.5.0

Step 3: Install Vue CLI on Ubuntu 22.04

Vue CLI is a command-line interface for building and scaffolding Vue.js projects.

Run the following command to install Vue CLI globally:

# npm install -g @vue/cli

Verify the Vue CLI installation by running the following command:

# vue --version

You should see the version number of Vue CLI installed on your system:

@vue/cli 5.0.8

Step 4: Create Vue.js Application

Now that we have installed Node.js and Vue CLI, we can create a Vue.js application.

You can create a Vue.js project run the following command:

# vue create linuxtuto-project

Sample Output:

You can accept the default options or customize them as needed.

Next, change the directory to the Vue.js application:

# cd linuxtuto-project

Once you are in the project folder you can start Vue.js application in development mode with the following command:

# npm run serve

By default the Vue.js  application start on port 8080.

Open your favorite browser and enter the URL http://your-IP-address:8080 to access your Vue.js application.

You should see the default Vue.js welcome page.

Conclusion

Congratulations. You have learned how to Install Vue.js and create a sample app on Ubuntu 22.04. Whether you’re a beginner or an experienced developer, Vue.js is a great choice for building web applications.

In order to get more information on this topic you can visiting the official website of Vue.js.

How To Secure Nginx with Let’s Encrypt on Ubuntu 22.04

Let’s Encrypt is a free, automated, and open-certificate authority (CA) that provides Digital SSL/TLS certificates to enable secure encrypted connections for websites. The goal of Let’s Encrypt is to make encryption widely accessible to everyone and to help create a more secure and privacy-respecting web.

Let’s Encrypt certificates are valid for 90 days and can be easily renewed. The certificate issuance and renewal process is fully automated, making it easy for website owners to secure their sites with HTTPS.

In addition to being free and easy to use, Let’s Encrypt is also transparent and collaborative, with a broad community of stakeholders who support its mission and contribute to its development.

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 Nginx webserver

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

$ sudo apt install nginx

Verify the status of the Nginx service using the following 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: 30128 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 30129 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 30218 (nginx)
      Tasks: 2 (limit: 2196)
     Memory: 10.1M
        CPU: 77ms
     CGroup: /system.slice/nginx.service
             ├─30218 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─30221 "nginx: worker process"

Step 3: Install Certbot on Ubuntu 22.04

Now we install the Certbot client which is used to create Let’s Encrypt certificates:

$ sudo apt install certbot python3-certbot-nginx

Verify that Certbot is installed and working properly:

$ certbot --version

You should see the version number of Certbot that you just installed:

certbot 1.21.0

Now you can use Certbot to obtain SSL certificates and configure your web server to use them.

Step 4: Configure Nginx Web Server

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

$ sudo nano /etc/nginx/sites-available/your-domain.com.conf

Add the following code to the file:

server {
        listen 80;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name your-domain.com www.your-domain.com;

        location / {
                try_files $uri $uri/ =404;
        }

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

}

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

Save and exit the configuration file.

Enable the new configuration file.

$ sudo ln -s /etc/nginx/sites-available/your-domain.com.conf /etc/nginx/sites-enabled/your-domain.com.conf

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 nginx

Step 5: Get the Let’s Encrypt SSL certificate

To get the SSL certificate using the Certbot, type the command given below:

$ sudo certbot --nginx

You will be asked to provide your valid email address and accept the term of service:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): admin@your-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Next, you’ll be asked if you want to share your email with the Electronic Frontier Foundation to receive news and other information. If you do not want to subscribe to their content, write N.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N

Next, you will be asked to select the domain on which you want to install the Let’s Encrypt SSL:

Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your-domain.com
2: www.your-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):

If the SSL certificate is successfully obtained, certbot displays a message to show the configuration was successful:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain.com.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-04-22. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Now, you have successfully installed SSL on your website.

You can now open your website using https://, and you’ll notice a green lock icon.

Step 6: Verifying Certbot Auto-Renewal

Verifying that Certbot’s auto-renewal is working correctly is an important step in ensuring that your website remains secure. You can verify Certbot’s auto-renewal by performing the following steps:

Check the Certbot Logs

The Certbot logs are the best place to start when verifying auto-renewal. The logs will contain information about any renewal attempts and any errors that may have occurred. You can access the Certbot logs by running the following command:

$ sudo cat /var/log/letsencrypt/letsencrypt.log

Test the Renewal Process

You can test the renewal process by manually running the Certbot renewal command. To do this, run the following command:

$ sudo certbot renew --dry-run

This will simulate a renewal attempt and will provide you with information about the outcome. If the renewal was successful, you should see a message indicating that the certificates were successfully renewed.

Check the Certificate Expiration Date

Finally, you can check the expiration date of your certificate to ensure that it has been renewed. You can do this by visiting your website and checking the certificate information in your browser’s security settings.

If you encounter any issues with the auto-renewal process, it is recommended that you reach out to the Let’s Encrypt community or consult the Certbot documentation for assistance.

Step 7: Revoking Let’s Encrypt certificates

To revoke a Let’s Encrypt SSL certificate, you can use the certbot revoke command.

First, stop your Nginx web server:

$ sudo systemctl stop nginx

Run the certbot revoke command, specifying the certificate you want to revoke:

$ sudo certbot revoke --cert-path /etc/letsencrypt/live/your-domain.com/fullchain.pem

Note: You’ll need to replace /etc/letsencrypt/live/your-domain.com/fullchain.pem with the actual path to your certificate file.

Start your web server again:

$ sudo systemctl start nginx

After revoking the certificate, the certificate will no longer be trusted by browsers and will no longer work for encrypting your website traffic.

This is useful if, for example, you need to transfer the domain to another owner or if you suspect that your private key has been compromised.

Comments and Conclusion

That’s it. Today, you had learn how to secure Nginx with Let’s Encrypt on Ubuntu 22.04.

If you have any questions or feedback, feel free to leave a comment.

How to Install Chamilo LMS on Ubuntu 22.04

Chamilo is an open-source learning management system (LMS) used for delivering online courses and training programs. It provides features such as course content management, student registration and progress tracking, online assessments, and collaboration tools. Chamilo is a free, web-based platform that can be customized to fit the needs of schools, businesses, and organizations.

In this tutorial, we will show you step-by-step how to install Chamilo on Ubuntu 22.04 OS.

Step 1: Update Operating System

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

# apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

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

# apt install apache2

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

# 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: 3489 (apache2)
      Tasks: 55 (limit: 2200)
     Memory: 4.8M
        CPU: 134ms
     CGroup: /system.slice/apache2.service
             ├─3489 /usr/sbin/apache2 -k start
             ├─3491 /usr/sbin/apache2 -k start
             └─3492 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions for Chamilo

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

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

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

# apt-get install php7.4 libapache2-mod-php7.4 php7.4-{cli,common,curl,zip,gd,mysql,xml,mbstring,json,intl,ldap,apcu}

Verify if PHP is installed.

php7.4 -v
Output:
PHP 7.4.33 (cli) (built: Jan 13 2023 10:42:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

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

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

Change the following settings per your requirements:

memory_limit = 512M
max_execution_time = 360
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = America/Chicago

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

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

# systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.6.11 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: 22423 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 22424 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 22427 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && >
    Process: 22492 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 22495 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 22463 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 2200)
     Memory: 61.0M
        CPU: 425ms
     CGroup: /system.slice/mariadb.service
             └─22463 /usr/sbin/mariadbd

By default, MariaDB is not hardened. You can secure MariaDB 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 MariaDB shell.

# mysql -u root -p

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

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

Step 5: Download Chamilo

Download the latest version of Chamilo. Find the newest version of this software on the official download page.

As of writing this tutorial, the latest stable version is 1.11.18.

# wget https://github.com/chamilo/chamilo-lms/releases/download/v1.11.18/chamilo-1.11.18.zip

Extract the downloaded package:

# apt install unzip
# unzip chamilo-1.11.18.zip

Copy the extracted files to the Apache web root directory:

# mv chamilo-1.11.18 /var/www/html/chamilo

Set the ownership and permissions of the Chamilo directory:

# chown -R www-data:www-data /var/www/html/chamilo
# chmod -R 755 /var/www/html/chamilo

Step 6: Configure Apache for Chamilo

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

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

Paste the content as shown below:

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

    <Directory /var/www/html/chamilo/> 
        AllowOverride All
        Require all granted
    </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.

Then enable the "rewrite" module in Apache:

# a2enmod rewrite

To enable this site run the command:

# a2ensite chamilo.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Access Chamilo Web Interface

To access the Chamilo installation wizard, go to your browser and visit http://your-domain.com.

Select the language you’d like to use when installing:

Then, you will see the system requirements screen:

At the bottom, you will see the New Installation button that you have to click:

Then, accept the application license:

Set your company name, your name, and email, as well as the language to use. This data will help the program to evolve.

Provide your database information and click on the Next.

Provide your site information and click on the Next.

You will see a summary of the installation:

Then, the installation will start and if everything went well, you will see the following screen:

To protect your config directory run the following command:

# chmod -R 555 /var/www/html/chamilo/app/config

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

# rm -r /var/www/html/chamilo/main/install

After deleting the folder go to http://your-domain.com/ and you will get the login page.

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

 

Comments and Conclusion

Congratulations! You have successfully installed Chamilo LMS. Thanks for using this tutorial for installing the Chamilo LMS on Ubuntu 22.04 OS.

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

How to Install Zen Cart on Ubuntu 22.04

Zen Cart is a free, open-source e-commerce application with wide community support. It is written in PHP and requires a MySQL database.

In this tutorial, we will show you how to install Zen Cart on Ubuntu 22.04 OS.

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

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: 47636 (apache2)
      Tasks: 55 (limit: 2200)
     Memory: 4.8M
        CPU: 126ms
     CGroup: /system.slice/apache2.service
             ├─47636 /usr/sbin/apache2 -k start
             ├─47638 /usr/sbin/apache2 -k start
             └─47639 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions for Zen Cart

By default, Ubuntu 22.04 comes with PHP version 8.1. To install PHP and additional PHP modules to support Zen Cart, run the following command:

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

Verify if PHP is installed.

php -v
Output:
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies

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

$ sudo nano /etc/php/8.1/apache2/php.ini

Change the following settings per your requirements:

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

To implement the changes, restart Apache webserver:

$ sudo systemctl restart apache2

Step 4: Install MariaDB and create a database

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.11 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: 59747 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 59748 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 59750 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && >
    Process: 59790 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 59792 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 59779 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2200)
     Memory: 61.0M
        CPU: 415ms
     CGroup: /system.slice/mariadb.service
             └─59779 /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 Zen Cart installation:

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

Step 5: Download Zen Cart

The latest version of Zen Cart is available to download from GitHub. As of writing this tutorial, the latest version available is 1.5.8.

$ sudo wget https://github.com/zencart/zencart/archive/refs/tags/v1.5.8.zip --no-check-certificate

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

$ sudo apt -y install unzip 
$ sudo unzip v1.5.8.zip -d /var/www/

Rename the extracted directory:

$ sudo mv /var/www/zencart-1.5.8 /var/www/zencart/

Then enable permission for the Apache webserver user to access the files:

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

Step 6: Configure Apache for Zen Cart

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

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

Paste the content as shown below:

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

    <Directory /var/www/zencart/> 
        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 zencart.conf

To implement the changes, restart Apache webserver:

$ sudo systemctl restart apache2

Step 7: Install free Let’s Encrypt SSL certificate

First we need to install the Certbot client which is used to create Let’s Encrypt certificates:

$ sudo apt install certbot python3-certbot-apache

To get the SSL certificate using the Certbot, type the command given below:

$ sudo certbot --apache -d your-domain.com -d www.your-domain.com

If the SSL certificate is successfully obtained, certbot displays a message to show the configuration was successful:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain.com.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-04-02. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Now, you have successfully installed SSL on your website.

Step 8: Access Zen Cart Web Interface

Open your web browser and type the URL https://your-domain.com/zc_install/index.php. You should see the following page:

Accept the license and click on the Continue.

Provide your database information and click the checkbox next to the Load Demo Data option. Then click on the Continue.

Establish a username and email address for the admin of the Zen Cart backend and click Continue.

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

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

# rm -rf /var/www/zencart/zc_install/

Then if you click on the Your Storefront you should see your shop page:

Or if you click on the Your Admin Dashboard button you should see the login page:

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

Comments and Conclusion

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

For additional help or useful information, we recommend you to check the documentation at the official Zen Cart website.

How to Install Mattermost on Ubuntu 22.04

Mattermost is an open-source, self-hosted chat and collaboration platform that is designed for modern teams. Mattermost is an alternative to Slack.

In this tutorial, we will show you the complete steps to install Mattermost on Ubuntu 22.04 with PostgreSQL database server.

Step 1: Update Operating System

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

# apt update && sudo 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 (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
    Process: 5421 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 5422 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 5423 (nginx)
      Tasks: 2 (limit: 2196)
     Memory: 6.7M
        CPU: 327ms
     CGroup: /system.slice/nginx.service
             ├─5423 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─5424 "nginx: worker process"

Step 3: Install PostgreSQL Database Server

Run the apt command to install:

# apt install postgresql postgresql-contrib

Once successfully installed, enable PostgreSQL (to start automatically upon system boot), start, and verify the status using the commands below:

# systemctl enable postgresql
# systemctl start postgresql
# systemctl status postgresql

Next, run the command below to log in to the PostgreSQL you just installed above:

su postgres
psql

Then, we create the Mattermost database:

postgres=# CREATE DATABASE mattermostdb; 
postgres=# CREATE USER mattermost WITH PASSWORD 'Mattermost-Strong-Password'; 
postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermostdb to mattermost; 
postgres=# \q

Return to your root user account.

# exit

Step 4: Create mattermost System user and group

We need to set up a system user and group called mattermost that will run service.

# useradd --system --user-group mattermost

You can confirm it is a system user since its ID is less than 1000.

# id mattermost
uid=998(mattermost) gid=998(mattermost) groups=998(mattermost)

Step 5: Installing Mattermost on Ubuntu 22.04

By default, Mattermost is not available on Ubuntu 22.04 base repository. Please visit the official releases page to get the latest release.

Run the following command to download the latest version of Mattermost to your Ubuntu system:

# wget https://releases.mattermost.com/7.5.2/mattermost-7.5.2-linux-amd64.tar.gz

Extract the downloaded file to /opt directory using tar command:

# tar xpvf mattermost-7.5.2-linux-amd64.tar.gz -C /opt

Create the data storage directory for the Mattermost server.

# mkdir /opt/mattermost/data

Set the correct permissions on files and directories:

# chown mattermost:mattermost /opt/mattermost/ -R

Step 6: Configure Mattermost Server

Edit the configuration file to set up the database driver.

# nano /opt/mattermost/config/config.json

Locate SqlSettings section and configure PostgreSQL database settings like bellow:

"DriverName": "postgres",

"DataSource": "postgres://mattermost:Mattermost-Strong-Password@localhost:5432/mattermostdb?sslmode=disable&connect_timeout=10",

Step 7: Create a Systemd service file

Create systemd unit for Mattermost to start / stop and restart service.

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

Paste following lines:

[Unit]
Description=Mattermost
After=network.target
After=postgresql.service
BindsTo=postgresql.service

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
  WantedBy=multi-user.target

Reload system daemon and start Mattermost Service:

# systemctl daemon-reload
# systemctl start mattermost
# systemctl enable mattermost

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

# systemctl status mattermost

Output:

 mattermost.service - Mattermost
     Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 4366 (mattermost)
      Tasks: 49 (limit: 2196)
     Memory: 539.5M
        CPU: 13.944s
     CGroup: /system.slice/mattermost.service
             ├─4366 /opt/mattermost/bin/mattermost
             ├─4395 plugins/com.mattermost.plugin-channel-export/server/dist/plugin-linux-amd64
             ├─4406 plugins/com.mattermost.calls/server/dist/plugin-linux-amd64
             ├─4419 plugins/playbooks/server/dist/plugin-linux-amd64
             ├─4427 plugins/focalboard/server/dist/plugin-linux-amd64
             └─4443 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64

Step 8: Configure Nginx for Mattermost

Then, create an virtual host configuration file:

# nano /etc/nginx/sites-available/mattermost.conf

Add the following code to the file:

server {
        listen 80;

        server_name mattermost.your-domain.com;
        root /opt/mattermost;

        error_log /var/log/nginx/mattermost.error;
        access_log /var/log/nginx/mattermost.access;

               location / {

        proxy_pass http://localhost:8065;

    }
}

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

Save and exit the configuration file.

Enable the new configuration file.

# ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf

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

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Step 9: Mattermost Setup and Configurations

Now open your web browser and go to http://mattermost.your-domain.com and you will see the following screen:

Next, you will be taken to the Team creation page:

Click the Create a team button to create your first team:

Then you will be asked to set a public URL for the team:

Click the Finish button to open the Mattermost Dashboard:

Comments and Conclusion

That’s it. You have successfully installed Mattermost on Ubuntu 22.04 with Nginx. For additional information, you can check the official Mattermost documentation.

If you have any questions please leave a comment below.

How To Secure Apache with Let’s Encrypt on Ubuntu 22.04

Let’s Encrypt is a free, automated, and open certificate authority (CA). Let’s Encrypt offer free 90-day SSL certificates.

Let’s Encrypt provide two types of certificates. The standard single-domain SSL and the Wildcard SSL, which covers not only a single domain, but all of its subdomains too.

In this tutorial, we will use Certbot a free, open-source software tool for automatically issuing the Let’s Encrypt SSL Certificate and verify that your certificate is set up to renew automatically.

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 on Ubuntu 22.04

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

Step 3: Install Certbot on Ubuntu 22.04

Now we install the Certbot client which is used to create Let’s Encrypt certificates:

$ sudo apt install certbot python3-certbot-apache

To verify the Certbot installation run:

$ certbot --version

Output:

certbot 1.21.0

Step 4: Configure Apache Web Server

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/your-domain.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/

<Directory /var/www/html/>
        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 Apache virtual host:

$ sudo a2ensite your-domain.conf

After that, restart the Apache web server.

$ sudo systemctl restart apache2

Step 5: Get the Let’s Encrypt SSL certificate

To get the SSL certificate using the Certbot, type the command given below:

$ sudo certbot --apache

You will be asked to provide your valid email address and accept the term of service:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): admin@your-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Next, you’ll be asked if you want to share your email with the Electronic Frontier Foundation to receive news and other information. If you do not want to subscribe to their content, write N.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N

Next, you will be asked to select the domain on which you want to install the Let’s Encrypt SSL:

Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your-domain.com
2: www.your-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):

If the SSL certificate is successfully obtained, certbot displays a message to show the configuration was successful:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain.com.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-03-22. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Now, you have successfully installed SSL on your website.

You can now open your website using https://, and you’ll notice a green lock icon.

Step 6: Verifying Certbot Auto-Renewal

Let’s Encrypt certificates are valid for only ninety days. Installing Certbot will create a cronjob to renew any SSL certificate. You can run the command to check the status of the service.

$ sudo systemctl status certbot.timer

Output:

 certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Thu 2022-12-22 16:20:05 CDT;
    Trigger: Fri 2022-12-23 06:29:34 CST; 14h left
   Triggers: ● certbot.service

Optionally, you can test the renewal process using the following command. The –dry-run flag is for simulation:

$ sudo certbot renew --dry-run --agree-tos

Step 7: Revoking certificates

If you wish to remove a certificate from your server it can be revoked using a subcommand with Let’s Encrypt client. The command below can be used to revoke a particular certificate.

$ sudo certbot revoke --cert-path /etc/letsencrypt/live/your-domain.com/cert.pem

Note: Replace your-domain.com with the domain which certificate you wish to revoke.

The process does not give a confirmation upon completion, but if you perform it again you will get a message that the certificate has already been revoked.

Comments and Conclusion

Congratulations! You have successfully installed the Let’s Encrypt SSL certificate on your domain.

If you have any questions or feedback, feel free to leave a comment.