How to Install Magento 2.4.6 on Ubuntu 22.04?

How to Install Magento 2.4.6 on Ubuntu 22.04?

Install Magento 2.4.6 on Ubuntu to improve the performance and scalability of your Magento ecommerce site. This release incorporates numerous quality fixes and improvements. The latest versions of core Composer dependencies and third-party libraries ensure compatibility with PHP 8.2.

This tutorial will guide you through the process of installing the Open Source version of Magento 2.4.6, specifically on the Ubuntu 22.04 operating system.

Key Takeaways

  • Discover how to install Magento 2.4.6 on Ubuntu 22.04 for enhanced ecommerce performance and scalability.

  • Explore the system requirements crucial for a seamless Magento 2.4.6 installation.

  • Learn how to customize PHP configuration for Magento 2.4.6 for efficient operation.

  • Discover the significance of Elasticsearch (7.9 or later) for advanced catalog search capabilities in Magento 2.4.6.

Magento 2.4.6 System Requirements

To ensure smooth installation and optimal performance of Magento 2.4.6, it's crucial to meet the following system requirements. The Magento Open Source Community has outlined these requirements for a seamless ecommerce experience:

1. Operating System

  1. Linux x86-64 (e.g., Red Hat Enterprise Linux, CentOS, Ubuntu, Debian, etc.)

  2. macOS (for local development environments)

2. Web Server

Magento 2.4.6 is compatible with the following web servers:

  1. Apache 2.4 or later

  2. NGINX 1.18 or later

3. Database

Choose from these supported databases:

  1. MySQL 8.0 or later

  2. MariaDB 10.4 or later

4. PHP Version

Ensure your server runs PHP 8.1 or a later version. Additionally, Magento 2.4.6 requires the following PHP extensions:

  • ext-bcmath
  • ext-ctype
  • ext-curl
  • ext-dom
  • ext-gd
  • ext-hash
  • ext-iconv
  • ext-intl
  • ext-mbstring
  • ext-openssl
  • ext-pdo_mysql
  • ext-simplexml
  • ext-soap
  • ext-xsl
  • ext-zip
  • ext-sockets
  • ext-xml
  • ext-xmlreader
  • ext-xmlwriter
  • lib-libxml (DOMDocument)

5. SSL

Ensure your setup includes a valid security certificate for secure transactions, as HTTPS is mandatory.

6. Additional Requirements

To facilitate the installation and functionality of Magento 2.4.6, the following tools are required:

  1. Composer 2.2 or later: A dependency management tool for PHP.

  2. Elasticsearch 7.9 or later: Required for efficient search capabilities.

Magento 2.4.6 Prerequisites

To get started with Magento 2.4.6, ensure two key prerequisites:

  1. System Requirements: Meet all Magento 2.4.6 system requirements as specified in the official documentation.

  2. Managed Hosting: Invest in a managed Magento hosting plan for a reliable foundation for your online store.

Steps for Magento 2.4.6 Installation on Ubuntu

Step 1: Update Operating System

Perform updates to keep your Ubuntu 22.04 OS current. It ensures your system is equipped with the latest package versions.

# apt update && sudo apt upgrade -y

Step 2: Install Nginx web server

Follow these steps to install and set up the Nginx web server:

  1. Install Nginx by running the following command:
# apt install nginx
  1. Once the installation is complete, start Nginx with this command:
# systemctl start nginx
  1. Ensure Nginx starts automatically on boot with the following command:
# systemctl enable nginx

Nginx is now installed, running, and configured to start on boot.

Step 3: Install PHP and PHP extensions

Ensure you have the right PHP version and extensions for Magento 2.4.6:

  1. Install PHP 8.1 with necessary extensions 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
  1. Verify if PHP is installed.
php -v
  1. You should see output similar to:
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

Step 4: Update php.ini file

Customize your PHP configuration for Magento 2.4.6 by following these steps:

  1. Find the PHP configuration file by running:
php --ini | grep "Loaded Configuration File"
  1. You'll get an output like:
Loaded Configuration File:         /etc/php/8.1/cli/php.ini
  1. Open the php.ini file for editing:
# nano /etc/php/8.1/cli/php.ini
  1. Modify the following settings in the php.ini file:
  • Set file_uploads to On
  • Set allow_url_fopen to On
  • Set short_open_tag to On
  • Increase memory_limit to 512M
  • Set upload_max_filesize to 128M
  • Increase max_execution_time to 3600
  1. Save the changes to the php.ini file.

  2. To apply the configuration changes, restart Nginx:

# systemctl restart nginx

Now, your PHP configuration is optimized to meet the requirements of Magento 2.4.6.

Step 5: Install MySQL 8 and create database

Set up MySQL 8 and create a database for Magento 2.4.6 by following these steps:

  1. Install MySQL with this command:
# apt install mysql-server
  1. Start the MySQL database server and enable it to start automatically on boot:
# systemctl start mysql
# systemctl enable mysql
  1. After installing and starting MySQL, access the MySQL prompt:
#  mysql -u root -p
  1. Within the MySQL prompt, execute the following commands to create a database, database user, and grant all privileges to the user.

Note: Customize 'magentodb,' 'magentouser,' and 'MyPassword' as needed:

mysql> CREATE DATABASE magentodb;
mysql> CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'MyPassword';
mysql> GRANT ALL ON magentodb.* TO 'magentouser'@'localhost';
mysql> EXIT

Step 6: Installing Elasticsearch

Configure Magento 2 Elasticsearch as the catalog search engine for Magento 2.4.6 with these steps:

  1. Import the Elasticsearch GPG key:
# wget -qO - | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
  1. Add the Elasticsearch repository:
# echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
  1. Update the apt package manager and install Elasticsearch:
# apt update && apt install elasticsearch
  1. Start and enable the Elasticsearch service:
# systemctl start elasticsearch
# systemctl enable elasticsearch
  1. Open the elasticsearch.yml file for editing:
sudo nano  /etc/elasticsearch/elasticsearch.yml
  1. Replace the following setting with 'false' to disable Magento security features:
# Enable security features false
  1. Save the changes to the elasticsearch.yml file.

  2. Restart the Elasticsearch service to apply the configuration:

# systemctl restart elasticsearch.service
  1. Verify that Elasticsearch runs correctly using the curl command:
# curl -X GET "localhost:9200/"
  1. If Elasticsearch is working correctly, you'll receive an output 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 7: Install Composer

  1. Download Composer using this command:
# curl -sS | php
  1. Move the Composer file to the /usr/local/bin path:
# mv composer.phar  /usr/local/bin/composer
  1. Grant execute permission to Composer:
# chmod +x   /usr/local/bin/composer
  1. Verify the Composer version to confirm the installation:
# composer --version
  1. You should see output similar to:
Composer version 2.5.4 2023-02-15 13:10:06

Step 8: Install Magento 2.4.6

  1. Installing Magento using the Marketplace by creating an access key is recommended.

  2. Generate Access keys by navigating to: My profile > Marketplace > My products > Access Keys.

  3. **Download Magento **2.4.6 data with the following command:

# composer create-project --repository-url= magento/project-community-edition=2.4.6 /var/www/magento2
  1. When prompted, provide your Public Key as the username and Private Key as the password.

  2. Navigate to the Magento directory:

# cd /var/www/magento2
  1. Set appropriate permissions for cache and static content folders:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
  1. Change the ownership of the Magento directory to the webserver user and adjust permissions:
# chown -R www-data:www-data /var/www/magento2
# chmod -R 755 /var/www/magento2
  1. Install Magento using the composer command. Customize the parameters according to your environment:
# bin/magento setup:install \
--base-url= \
--db-host=localhost \
--db-name=magentodb \
--db-user=magentouser \
--db-password=MyPassword \
--admin-firstname=Admin \
--admin-lastname=User \ \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
  1. You will receive the admin link for your Magento site after successful installation.
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_o07lew
Nothing to import.

Step 9: Configure Nginx Web Server for Magento 2.4.6

  1. Navigate to the Nginx configuration directory:
cd /etc/nginx/conf.d
  1. Create a configuration file for your Magento installation:
# nano /etc/nginx/conf.d/magento2.conf
  1. Add the following content to the file, customizing it as needed (replace with your actual domain):
upstream fastcgi_backend {
  server  unix:/run/php/php8.1-fpm.sock;

server {

  listen 80;
  set $MAGE_ROOT /var/www/magento2;
  include /var/www/magento2/nginx.conf.sample;
  1. Save the file and exit the text editor.

  2. Restart the Nginx web server to apply the configuration changes:

# systemctl restart nginx

Step 10: Access your Magento 2.4.6 Application

Now that your Magento 2 installation is set up, access it through your web browser:

  1. Open your preferred web browser.
  2. In the address bar, type your domain, e.g.,


1. What are the system requirements for installing Magento 2.4.6 on Ubuntu 22.04?

Magento 2.4.6 requires a Linux x86-64 operating system, such as Ubuntu 22.04 or Debian 11, and is compatible with web servers like Apache 2.4 or later and NGINX 1.18 or later. Also, ensure PHP 8.1 or later with specified extensions, MySQL 8.0 or later, and a valid SSL certificate for secure transactions.

2. Why is Elasticsearch necessary for Magento 2.4.6 installation?

Elasticsearch, version 7.9 or later, is crucial for efficient catalog search in Magento 2.4.6. It enhances the search functionality, providing a seamless experience for users navigating your online store.

3. How can I customize the PHP configuration for Magento 2.4.6?

To customize PHP for Magento 2.4.6, locate the php.ini file, typically at /etc/php/8.1/cli/php.ini. Adjust settings like file_uploads, allow_url_fopen, memory_limit, and more. After modification, restart Nginx to apply the changes.

4. What is the significance of Composer in Magento 2.4.6 installation?

Composer, version 2.2 or later, is a dependency management tool for PHP. It plays a crucial role in downloading and managing Magento 2.4.6 components, ensuring a streamlined installation process.

5. How do I access my Magento 2.4.6 application after installation?

Once installed, access your Magento 2.4.6 application by opening your preferred web browser and entering your domain, such as, into the address bar. It will lead you to the configured Magento site.


To install Magento 2.4.6 on Ubuntu is a straightforward process that can be done step-by-step. It allows you to harness the new features and enhancements in Magento 2.4.6, all within the secure framework of the Ubuntu operating system. This tutorial covered the steps to install Magento 2.4.6 on Ubuntu 22.04. It also highlighted system prerequisites, Nginx web server setup, PHP configuration, and Elasticsearch integration.

Choose a reliable Magento server hosting plan to ensure a solid base for your Magento 2.4.6 installation.

Maria Ajnawala
Maria Ajnawala
Technical Writer

Maria has over five years of expertise in content marketing, specialising in Magento insights and industry trends. She excels in creating engaging content that resonates within the Magento community.

Get the fastest Magento Hosting! Get Started