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
-
Linux x86-64 (e.g., Red Hat Enterprise Linux, CentOS, Ubuntu, Debian, etc.)
-
macOS (for local development environments)
2. Web Server
Magento 2.4.6 is compatible with the following web servers:
-
Apache 2.4 or later
-
NGINX 1.18 or later
3. Database
Choose from these supported databases:
-
MySQL 8.0 or later
-
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:
-
Composer 2.2 or later: A dependency management tool for PHP.
-
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:
-
System Requirements: Meet all Magento 2.4.6 system requirements as specified in the official documentation.
-
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:
- Install Nginx by running the following command:
# apt install nginx
- Once the installation is complete, start Nginx with this command:
# systemctl start nginx
- 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:
- 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
- Verify if PHP is installed.
php -v
- 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:
- Find the PHP configuration file by running:
php --ini | grep "Loaded Configuration File"
- You'll get an output like:
Loaded Configuration File: /etc/php/8.1/cli/php.ini
- Open the php.ini file for editing:
# nano /etc/php/8.1/cli/php.ini
- 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
-
Save the changes to the php.ini file.
-
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:
- Install MySQL with this command:
# apt install mysql-server
- Start the MySQL database server and enable it to start automatically on boot:
# systemctl start mysql
# systemctl enable mysql
- After installing and starting MySQL, access the MySQL prompt:
# mysql -u root -p
- 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> FLUSH PRIVILEGES;
mysql> EXIT
Step 6: Installing Elasticsearch
Configure Magento 2 Elasticsearch as the catalog search engine for Magento 2.4.6 with these steps:
- 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
- Start and enable the Elasticsearch service:
# systemctl start elasticsearch
# systemctl enable elasticsearch
- Open the elasticsearch.yml file for editing:
sudo nano /etc/elasticsearch/elasticsearch.yml
- Replace the following setting with 'false' to disable Magento security features:
# Enable security features
xpack.security.enabled: false
-
Save the changes to the elasticsearch.yml file.
-
Restart the Elasticsearch service to apply the configuration:
# systemctl restart elasticsearch.service
- Verify that Elasticsearch runs correctly using the curl command:
# curl -X GET "localhost:9200/"
- 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
- Download Composer using this command:
# curl -sS https://getcomposer.org/installer | php
- Move the Composer file to the
/usr/local/bin
path:
# mv composer.phar /usr/local/bin/composer
- Grant execute permission to Composer:
# chmod +x /usr/local/bin/composer
- Verify the Composer version to confirm the installation:
# composer --version
- You should see output similar to:
Composer version 2.5.4 2023-02-15 13:10:06
Step 8: Install Magento 2.4.6
-
Installing Magento using the Marketplace by creating an access key is recommended.
-
Generate Access keys by navigating to: My profile > Marketplace > My products > Access Keys.
-
**Download Magento **2.4.6 data with the following command:
# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6 /var/www/magento2
-
When prompted, provide your Public Key as the username and Private Key as the password.
-
Navigate to the Magento directory:
# cd /var/www/magento2
- 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 {} +
- 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
- Install Magento using the composer command. Customize the parameters according to your environment:
# 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
- 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
- Navigate to the Nginx configuration directory:
cd /etc/nginx/conf.d
- Create a configuration file for your Magento installation:
# nano /etc/nginx/conf.d/magento2.conf
- Add the following content to the file, customizing it as needed (replace
your-domain.com
with your actual domain):
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 the text editor.
-
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:
- Open your preferred web browser.
- In the address bar, type your domain, e.g.,
http://your-domain.com
FAQs
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 http://your-domain.com
, into the address bar. It will lead you to the configured Magento site.
Summary
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.