FedoraRHEL Based

How To Install Magento on Fedora 41

Install Magento on Fedora 41

Magento is a robust and highly customizable open-source eCommerce platform used by businesses of all sizes. Its flexibility, extensive feature set, and large community make it a top choice for managing an online store. While it can be deployed on various operating systems, Fedora 41 offers an up-to-date environment with the latest software packages, security enhancements, and stability improvements. This detailed guide provides everything you need to install Magento on Fedora 41, ensuring a smooth and secure setup of your new eCommerce storefront.

Introduction

As digital commerce grows exponentially, having a reliable, high-performance eCommerce platform is more critical than ever. Magento, developed in PHP, is known for its robust architecture and extensive library of extensions, allowing businesses to scale and adapt as they grow. Fedora 41, a leading-edge Linux distribution sponsored by Red Hat, offers a stable environment for hosting Magento. Using Fedora 41 means benefiting from the latest kernel improvements, optimized system libraries, and modern security mechanisms.

In this guide, you will learn how to install and configure Magento on Fedora 41. We will cover everything from system prerequisites and server preparation to performance optimization and best security practices. By following these steps, you can ensure your Magento store runs smoothly, remains secure, and takes full advantage of Fedora 41’s cutting-edge features.

Prerequisites

Hardware Requirements

Before you install Magento on Fedora 41, make sure your server meets the minimum hardware specifications:

  • CPU: 2GHz or faster quad-core processor
  • RAM: At least 4GB of memory (8GB or more recommended for production sites)
  • Storage: 20GB of available disk space (SSD recommended)

Software Requirements

To run Magento effectively on Fedora 41, ensure you have the following software components:

  • PHP: Version 8.1 or 8.2 (including required extensions like mbstring, intl, gd, curl, xml, xsl, and zip)
  • Database: MySQL 5.7+ or MariaDB 10.4+
  • Web Server: Apache 2.4 or Nginx (we will cover Apache in this tutorial)
  • Elasticsearch: Version 7.9+ for Magento’s catalog search functionality
  • Composer: Version 2.2+ for managing Magento’s PHP dependencies

Having these requirements met allows Magento to function properly, handle large volumes of traffic, and remain compatible with future updates.

System Preparation

Preparing your Fedora 41 system is the first step toward a successful Magento installation. This involves keeping the system packages up to date, configuring key repositories, and setting appropriate security measures. Proper initial configuration ensures that your environment is both stable and secure for hosting an eCommerce platform.

Update Your System

Keeping your system current with the latest updates and security patches is essential. Perform a full update using:

sudo dnf update -y

This command brings all system packages to their latest stable versions. After the update, it’s often a good practice to reboot, particularly if the kernel or core system libraries were updated:

sudo reboot

Configure Repositories

Magento requires certain PHP extensions that might not be available in Fedora’s default repository. You can enable the Remi repository for up-to-date PHP packages:

sudo dnf install dnf-plugins-core -y
sudo dnf install https://rpms.remirepo.net/fedora/remi-release-41.rpm -y

Once enabled, you will have easier access to the latest versions of PHP extensions necessary for Magento to operate efficiently.

Security Settings

Fedora 41 includes built-in SELinux and FirewallD. While SELinux offers additional security, it may require extra configuration for Magento. You can keep SELinux enforcing and configure it properly, or set it to permissive until the Magento installation is confirmed stable. Adjust the FirewallD rules to allow HTTP (port 80) and HTTPS (port 443) traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Install and Configure the LAMP Stack

One of the most popular server setups for Magento uses the LAMP stack (Linux, Apache, MySQL/MariaDB, and PHP). Below is a step-by-step guide to installing and configuring these components on Fedora 41.

1. Install Apache

Apache is a widely used open-source web server. Install and enable it on Fedora:

sudo dnf install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd

Verify that Apache is active:

systemctl status httpd

If Apache is running without errors, navigate to http://your_server_ip in your browser. You should see the default Apache test page confirming a successful installation.

2. Install MySQL or MariaDB

You can choose either MySQL or MariaDB for your database server. MariaDB is a fork of MySQL and is readily available in Fedora’s default repositories:

sudo dnf install mariadb-server -y
sudo systemctl enable mariadb
sudo systemctl start mariadb

Run the secure installation script to protect your database:

sudo mysql_secure_installation

Follow the prompts to set a strong root password, remove anonymous users, disable remote root login if not needed, and remove test databases.

3. Install and Configure PHP

Magento relies on PHP 8.1 or higher. Using the Remi repository ensures you have the latest packages:

sudo dnf module reset php -y
sudo dnf module install php:remi-8.1 -y

After this, install the necessary PHP extensions for Magento:

sudo dnf install php php-bcmath php-intl php-gd php-curl php-mbstring php-xml \
php-zip php-soap php-opcache php-cli php-common php-json -y

Restart Apache to load these new modules:

sudo systemctl restart httpd

PHP Configuration

With PHP installed, it is vital to adjust its configuration for Magento’s specific needs. Magento’s default configuration requires higher memory limits and longer execution times, especially during the installation process or when handling large catalogs.

1. Update PHP Memory Limit

Open the /etc/php.ini file or its equivalent in your distribution and increase the memory limit:

sudo nano /etc/php.ini

Locate the setting and change it to a more suitable value such as:

memory_limit = 512M

2. Adjust max_execution_time

Magento sometimes requires longer execution times when installing extensions or performing intensive tasks:

max_execution_time = 300

Save and exit the file. Then, restart Apache:

sudo systemctl restart httpd

With these adjustments, your server can handle the heavier load that Magento frequently places on PHP.

Database Setup

Properly configuring your database is critical for Magento to operate smoothly. Taking a little extra time to create secure credentials and set correct privileges will enhance both performance and security.

Create a Magento Database

Log into your MariaDB or MySQL server:

sudo mysql -u root -p

Once inside the MySQL prompt, create a new database for Magento (replace magento_db with your preferred name):

CREATE DATABASE magento_db;

User Privileges

Next, create a dedicated user and assign it the necessary privileges. Use a strong, unique password for security:

CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON magento_db.* TO 'magento_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Your database is now ready for the Magento installation.

Magento Installation

Installing Magento on Fedora 41 involves downloading the platform files, setting up Composer, verifying file permissions, and running the installation wizard or command-line script. This is a more extensive portion of the deployment.

1. Install Composer

Composer is crucial for managing the dependencies required by Magento. Install Composer globally:

sudo dnf install composer -y

Once installed, verify the version:

composer --version

2. Download Magento Files

There are multiple methods to obtain Magento. You can download it directly from Adobe Commerce, or you can use Composer. Here we’ll use the Composer approach. Navigate to the Apache web directory, or any location you intend to store Magento:

cd /var/www/html
sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento

During the process, you will be prompted for Magento authentication keys. You can generate these keys from your Adobe Commerce account. Enter the public key as the username and the private key as the password.

3. Set Correct File Permissions

Magento requires proper file and directory ownership for seamless updates and security. Run:

sudo chown -R apache:apache /var/www/html/magento
sudo find /var/www/html/magento -type f -exec chmod 644 {} \;
sudo find /var/www/html/magento -type d -exec chmod 755 {} \;

You may also need SELinux permissions if SELinux is enforcing:

sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/magento

4. Run the Magento Installation

Run the installation from the command line:

cd /var/www/html/magento
bin/magento setup:install \
--base-url="http://your_server_ip/magento" \
--db-host="localhost" \
--db-name="magento_db" \
--db-user="magento_user" \
--db-password="SecurePassword123!" \
--admin-firstname="FirstName" \
--admin-lastname="LastName" \
--admin-email="admin@example.com" \
--admin-user="admin" \
--admin-password="AdminPassword123!" \
--language="en_US" \
--currency="USD" \
--timezone="America/New_York" \
--use-rewrites=1

After a successful installation, Magento will provide the admin URL path. Copy that and keep it safe for future reference.

Post-Installation Tasks

With Magento installed, there are a few essential tasks to ensure your eCommerce store remains secure, performant, and up to date.

1. Set Up the Cron Job

Magento relies on cron jobs for various background tasks like indexing, sending email notifications, and generating sitemaps. Create a cron job in your server’s crontab:

sudo crontab -u apache -e

Then add the following lines:

*/5 * * * * /usr/bin/php /var/www/html/magento/bin/magento cron:run
*/5 * * * * /usr/bin/php /var/www/html/magento/update/cron.php
*/5 * * * * /usr/bin/php /var/www/html/magento/bin/magento setup:cron:run

2. Cache Configuration

Magento provides multiple caching mechanisms to speed up page loads. By default, file-based caching is enabled. You can improve performance further by integrating Redis for caching and session management. Modify the env.php file located in app/etc to configure Redis if you wish to leverage in-memory caching.

3. Security Measures

Immediately secure your admin panel by using strong credentials, changing the default admin URL, and enabling two-factor authentication. Consider implementing an SSL certificate to protect sensitive data during transmission.

Performance Optimization

Magento can be resource-intensive. Proper optimization ensures a smoother shopping experience and faster load times, both of which are vital for customer satisfaction and SEO rankings.

1. Apache Optimization

Enable Apache’s mod_rewrite, mod_headers, and mod_expires modules to leverage browser caching:

sudo a2enmod rewrite headers expires
sudo systemctl restart httpd

Set up compression and caching headers within your Apache virtual host file to reduce page load times and bandwidth usage.

2. PHP-FPM Configuration

Switching from default Apache PHP handler to PHP-FPM can boost performance. Install and enable PHP-FPM:

sudo dnf install php-fpm -y
sudo systemctl enable php-fpm
sudo systemctl start php-fpm

Update your Apache configuration to use PHP-FPM’s socket, which helps handle multiple requests more efficiently.

3. Caching Strategies

Integrate Varnish Cache to further expedite content delivery. Varnish acts as a reverse proxy and caches dynamic content, significantly reducing server load. Magento natively supports Varnish configuration, making setup relatively straightforward.

Troubleshooting

Even with a well-planned setup, you may encounter issues during or after installation. Below are common challenges and potential fixes:

1. File Permission Errors

If you see alerts about insufficient write permissions, verify ownership and SELinux context:

sudo chown -R apache:apache /var/www/html/magento
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/magento

2. Database Connection Problems

Ensure your credentials in env.php match the database user and password. Also, verify your database server is running and listening on the correct port (default 3306).

3. Blank Pages or White Screen

A blank page typically indicates a PHP issue or misconfiguration. Check your PHP error logs in /var/log/httpd or /var/log/php-fpm (if using PHP-FPM).

Congratulations! You have successfully installed Magento. Thanks for using this tutorial for installing the Magento eCommerce Marketing Platform on your Fedora 41 system. For additional help or useful information, we recommend you check the official Magento website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button