How to Install Magento 2.4.6 on Ubuntu 22.04? A Step-by-Step Guide
Install Magento 2.4.6 on Ubuntu 22.04 ensures optimal performance and scalability for your eCommerce store. The latest release includes numerous quality improvements and compatibility with PHP 8.2, making it a reliable choice for your online business.
This guide walks you through the complete installation process, covering system requirements, prerequisites, and step-by-step instructions to set up Magento 2.4.6 on Ubuntu 22.04.
Magento 2.4.6 System Requirements
To ensure a smooth installation, your server must meet the following requirements:
- Operating System: Ubuntu 22.04 (Recommended) or other Linux distributions
- Web Server: Apache 2.4+ or Nginx 1.18+
- Database: MySQL 8.0+ or MariaDB 10.4+
- PHP Version: PHP 8.1+ with required extensions
- SSL Certificate: HTTPS is mandatory
- Additional Tools: Composer 2.2+, Elasticsearch 7.9+
Prerequisites for Magento 2.4.6 Installation
Before installation, ensure:
- Your server meets all system requirements.
- You have a managed Magento hosting plan for a stable environment.
Steps to Installing Magento 2.4.6 on Ubuntu 22.04
1 Step: Update Your System
Run the following command to update your Ubuntu system:
sudo apt update && sudo apt upgrade -y
2 Step: Install Nginx Web Server
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
3 Step: Install PHP and Required Extensions
sudo apt install php php-fpm php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml -y
php -v
4 Step: Update PHP Configuration
Modify php.ini settings:
sudo nano /etc/php/8.1/cli/php.ini
Change the following values:
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 512M
upload_max_filesize = 128M
max_execution_time = 3600
Save and exit, then restart Nginx:
sudo systemctl restart nginx
Step 5: Install MySQL and Create a Database
sudo apt install mysql-server -y
sudo systemctl start mysql
sudo systemctl enable mysql
Create a database for Magento:
mysql -u root -p
CREATE DATABASE magentodb;
CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'MyPassword';
GRANT ALL ON magentodb.* TO 'magentouser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 6: Install Elasticsearch
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
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
sudo apt update && sudo apt install elasticsearch -y
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
Edit the configuration file:
sudo nano /etc/elasticsearch/elasticsearch.yml
Set the following:
xpack.security.enabled: false
Restart Elasticsearch:
sudo systemctl restart elasticsearch
Step 7: Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
composer --version
Step 8: Install Magento 2.4.6
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6 /var/www/magento2
Enter your Public Key as username and Private Key as password.
Navigate to the directory:
cd /var/www/magento2
Set permissions:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
sudo chown -R www-data:www-data /var/www/magento2
sudo chmod -R 755 /var/www/magento2
Run the Magento installation command:
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
Step 9: Configure Nginx for Magento
sudo nano /etc/nginx/conf.d/magento2.conf
Add:
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;
}
Restart Nginx:
sudo systemctl restart nginx
Step 10: Access Magento 2.4.6
Open your browser and visit:
http://your-domain.com
FAQs
1. Why is Elasticsearch required? It improves search capabilities, making catalog searches efficient.
2. How to modify PHP settings? Edit php.ini and restart Nginx to apply changes.
3. What is Composer’s role? It manages dependencies and simplifies Magento installation.
For information regarding Magento click here : Link
Conclusion
Installing Magento 2.4.6 on Ubuntu 22.04 enhances eCommerce performance with advanced search, scalability, and security. Follow this guide to set up your store efficiently.
Stay updated with Infoblend.in for the latest insights on workforce trends and industry news.