How To Install Magento on Fedora 42
Magento stands as one of the most powerful open-source eCommerce platforms available today, powering thousands of online stores worldwide. Its robust feature set, extensive customization capabilities, and scalability make it an ideal choice for businesses ranging from small startups to large enterprises. When paired with Fedora 42, a cutting-edge Linux distribution known for its stability and performance, you create a formidable foundation for your online store. This comprehensive guide walks through every step of installing Magento on Fedora 42, from initial system preparation to post-installation optimization. Whether you’re launching a new eCommerce venture or migrating an existing store, this tutorial provides the detailed instructions needed to successfully deploy Magento on your Fedora server.
Understanding Magento System Requirements
Before diving into the installation process, understanding Magento’s system requirements ensures a smooth deployment without compatibility issues. Magento 2.4.x requires specific software components to function properly.
The minimum hardware specifications include at least 2GB of RAM, though 4GB or more is recommended for production environments handling significant traffic. Your processor should support 64-bit architecture, and allocate at least 10GB of disk space for the Magento installation itself, plus additional storage for product images, media files, and database growth.
On the software side, Magento demands precise versions. The operating system must be Linux x86-64 compatible, making Fedora 42 an excellent choice. Apache 2.4 serves as the recommended web server, providing reliable performance and extensive module support. PHP versions 8.1, 8.2, or 8.3 are required depending on your Magento version, with each offering improved performance over previous releases. Database requirements specify MySQL 8.0 or MariaDB 10.6 or higher for data storage. The search engine component requires either OpenSearch 2.x or Elasticsearch, enabling fast catalog search functionality. Finally, Composer 2.2 or later manages PHP dependencies and facilitates the installation process.
Critical PHP extensions include ext-bcmath for arbitrary precision mathematics, ext-ctype for character type checking, ext-curl for URL transfers, ext-dom for DOM operations, ext-gd for image processing, ext-hash for hashing algorithms, ext-iconv for character encoding conversion, ext-intl for internationalization, ext-mbstring for multibyte string handling, ext-openssl for secure communications, ext-pdo_mysql for database connectivity, ext-simplexml for XML parsing, ext-soap for SOAP protocol support, ext-sodium for cryptography, ext-xsl for XSLT transformations, and ext-zip for archive handling. These extensions enable Magento’s core functionality and should not be overlooked.
Prerequisites Before Installation
Successful Magento installation requires preparation before executing commands. Root or sudo access to your Fedora 42 server is essential for installing packages and configuring system services. While optional, having a registered domain name provides a professional appearance and simplifies SSL certificate configuration later.
Creating an Adobe Commerce account is mandatory for obtaining authentication keys. Visit the Magento Marketplace and register for a free account. Navigate to your account settings and locate the “Access Keys” section under “Marketplace”. Generate a new access key pair, which produces a public key (username) and private key (password). Store these credentials securely as they’re required during the Composer installation phase. Basic command-line knowledge helps you navigate the installation process confidently, though this guide provides all necessary commands. SSH access to your server enables remote administration and is the standard method for managing Linux servers.
Step 1: Update System Packages
Updating your Fedora 42 system before installing new software ensures compatibility and security. Begin by refreshing the package repository metadata to fetch the latest available versions:
sudo dnf check-update
This command queries all configured repositories for updated packages. Next, upgrade all installed packages to their newest versions:
sudo dnf upgrade -y
The -y
flag automatically confirms the upgrade without prompting. Remove unnecessary dependencies and orphaned packages:
sudo dnf autoremove -y
Verify the system is current by checking for remaining updates. If kernel updates were applied, reboot your server to load the new kernel:
sudo reboot
Wait a few minutes for the system to restart, then reconnect via SSH.
Step 2: Install and Configure Apache Web Server
Apache HTTP Server handles incoming web requests and serves Magento pages to visitors. Install Apache using Fedora’s DNF package manager:
sudo dnf install httpd -y
Start the Apache service immediately:
sudo systemctl start httpd
Enable Apache to launch automatically at system boot:
sudo systemctl enable httpd
Verify Apache is running correctly:
sudo systemctl status httpd
You should see “active (running)” in the output. Configure your firewall to allow HTTP and HTTPS traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
These commands open ports 80 and 443, enabling web traffic to reach your server. Test Apache by visiting your server’s IP address in a web browser; you should see the default Fedora test page.
Step 3: Install PHP and Required Extensions
PHP powers Magento’s backend logic and requires specific versions and extensions. Fedora 42 typically includes recent PHP versions in its repositories. Install PHP along with all required extensions:
sudo dnf install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-intl php-soap php-opcache php-sodium -y
This single command installs PHP and the extensions Magento requires. Verify the PHP installation and version:
php -v
You should see PHP 8.1 or later. Next, configure PHP settings to meet Magento’s requirements. Edit the php.ini file:
sudo nano /etc/php.ini
Locate and modify these parameters:
memory_limit = 2048M
max_execution_time = 3600
upload_max_filesize = 256M
post_max_size = 256M
zlib.output_compression = On
date.timezone = Asia/Jakarta
The memory limit of 2048M provides adequate resources for Magento operations. Maximum execution time of 3600 seconds allows complex operations to complete. Upload limits accommodate large product images and media files. Output compression reduces bandwidth usage. Set the timezone to match your server location. Save the file and restart Apache to apply changes:
sudo systemctl restart httpd
Verify PHP is working with Apache by creating a test file:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Visit http://your-server-ip/info.php
in your browser to see PHP configuration details. Remove this file after verification for security:
sudo rm /var/www/html/info.php
Step 4: Install and Configure MySQL/MariaDB Database
Magento stores product data, customer information, and orders in a relational database. Choose either MySQL or MariaDB; this guide uses MariaDB. Install MariaDB server:
sudo dnf install mariadb-server -y
Start the database service:
sudo systemctl start mariadb
Enable MariaDB to start on boot:
sudo systemctl enable mariadb
Secure the MariaDB installation by running the security script:
sudo mysql_secure_installation
Press Enter when prompted for the current root password (there isn’t one yet). Set a strong root password when prompted. Answer ‘Y’ to remove anonymous users, disallow root login remotely, remove test database, and reload privilege tables.
Log into the MariaDB shell:
sudo mysql -u root -p
Enter your root password. Create a dedicated database for Magento:
CREATE DATABASE magento_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
The utf8mb4 character set ensures full Unicode support. Create a database user with a strong password:
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
Replace ‘StrongPassword123!’ with a secure password. Grant privileges to this user:
GRANT ALL PRIVILEGES ON magento_db.* TO 'magento_user'@'localhost';
Flush privileges to apply changes:
FLUSH PRIVILEGES;
Exit the MariaDB shell:
EXIT;
Test the new user’s access:
mysql -u magento_user -p magento_db
If you successfully connect, the database is ready.
Step 5: Install OpenSearch Search Engine
OpenSearch powers Magento’s catalog search functionality, enabling fast product lookups. First, install Java Runtime Environment, which OpenSearch requires:
sudo dnf install java-11-openjdk -y
Verify Java installation:
java -version
Import the OpenSearch GPG key and add the repository:
sudo rpm --import https://artifacts.opensearch.org/publickeys/opensearch.pgp
Create a repository configuration file:
sudo nano /etc/yum.repos.d/opensearch-2.x.repo
Add this content:
[opensearch-2.x]
name=OpenSearch repository for 2.x packages
baseurl=https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/yum
gpgcheck=1
gpgkey=https://artifacts.opensearch.org/publickeys/opensearch.pgp
enabled=1
autorefresh=1
type=rpm-md
Save and exit. Install OpenSearch:
sudo dnf install opensearch -y
Configure OpenSearch for Magento. Edit the configuration file:
sudo nano /etc/opensearch/opensearch.yml
Modify these settings:
cluster.name: magento-cluster
node.name: node-1
network.host: 127.0.0.1
discovery.type: single-node
These settings configure OpenSearch for a single-node deployment suitable for most Magento installations. Start OpenSearch:
sudo systemctl start opensearch
Enable it to start on boot:
sudo systemctl enable opensearch
Verify OpenSearch is running:
curl -X GET http://localhost:9200
You should receive a JSON response with cluster information.
Step 6: Install Composer Dependency Manager
Composer manages PHP dependencies and streamlines the Magento installation process. Download the Composer installer:
curl -sS https://getcomposer.org/installer -o composer-setup.php
Verify the installer’s integrity (optional but recommended). Install Composer globally:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Remove the installer script:
rm composer-setup.php
Verify Composer installation:
composer --version
You should see Composer 2.2 or later. Configure Composer authentication for Magento repositories. Create a global auth.json file:
mkdir ~/.composer
nano ~/.composer/auth.json
Add your Magento authentication keys:
{
"http-basic": {
"repo.magento.com": {
"username": "YOUR_PUBLIC_KEY",
"password": "YOUR_PRIVATE_KEY"
}
}
}
Replace the placeholders with your actual Magento Marketplace keys. Save the file with restrictive permissions:
chmod 600 ~/.composer/auth.json
Step 7: Download Magento Using Composer
Navigate to the Apache document root:
cd /var/www/html
Create a directory for Magento and navigate into it:
sudo mkdir magento2
cd magento2
Use Composer to download Magento. This command fetches the latest 2.4.x version:
sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
The period at the end installs Magento in the current directory. This process downloads numerous packages and may take several minutes. Composer will prompt for your authentication keys if not found in auth.json.
After download completes, set proper ownership to the Apache user:
sudo chown -R apache:apache /var/www/html/magento2
Set appropriate permissions for directories and files:
cd /var/www/html/magento2
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
sudo chmod u+x bin/magento
These commands ensure Apache can write to necessary directories while maintaining security.
Step 8: Configure Apache Virtual Host for Magento
Create a dedicated virtual host configuration for Magento. Create a new configuration file:
sudo nano /etc/httpd/conf.d/magento.conf
Add this virtual host configuration:
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/html/magento2/pub
<Directory /var/www/html/magento2/pub>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/magento_error.log
CustomLog /var/log/httpd/magento_access.log combined
</VirtualHost>
Replace yourdomain.com
with your actual domain name. The DocumentRoot points to the pub
directory, not the Magento root, which is a security best practice. Save the file and test Apache configuration syntax:
sudo apachectl configtest
You should see “Syntax OK”. Restart Apache to apply the new configuration:
sudo systemctl restart httpd
If testing locally without a domain, add an entry to your hosts file:
sudo nano /etc/hosts
Add:
127.0.0.1 yourdomain.com
Step 9: Run Magento Installation Command
Navigate to the Magento root directory:
cd /var/www/html/magento2
Execute the Magento installation command with all required parameters:
sudo -u apache bin/magento setup:install \
--base-url=http://yourdomain.com/ \
--db-host=localhost \
--db-name=magento_db \
--db-user=magento_user \
--db-password='StrongPassword123!' \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@yourdomain.com \
--admin-user=admin \
--admin-password='Admin123!' \
--language=en_US \
--currency=USD \
--timezone=Asia/Jakarta \
--use-rewrites=1 \
--search-engine=opensearch \
--opensearch-host=localhost \
--opensearch-port=9200
Replace all placeholder values with your actual information. The admin password must contain uppercase, lowercase, numbers, and special characters. This installation process takes several minutes as Magento configures the database, compiles code, and deploys static content.
Upon successful completion, you’ll see a message with your admin URI, which looks like:
[SUCCESS]: Magento Admin URI: /admin_1a2b3c
Save this URI as you’ll need it to access the admin panel. The random suffix prevents automated attacks on the admin login page.
Step 10: Post-Installation Configuration
Set Magento to the appropriate mode. For production, use:
sudo -u apache bin/magento deploy:mode:set production
For development environments, use developer mode instead. Deploy static content for faster page loads:
sudo -u apache bin/magento setup:static-content:deploy -f
Compile dependency injection configuration:
sudo -u apache bin/magento setup:di:compile
This optimizes Magento’s code. Reindex all data:
sudo -u apache bin/magento indexer:reindex
Clear and flush the cache:
sudo -u apache bin/magento cache:clean
sudo -u apache bin/magento cache:flush
Set final file permissions:
cd /var/www/html/magento2
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
Step 11: Configure Cron Jobs for Magento
Magento relies on cron jobs for essential background tasks like reindexing, sending emails, generating sitemaps, and applying catalog price rules. Install Magento cron jobs:
sudo -u apache bin/magento cron:install
This command adds three cron entries to the Apache user’s crontab. Verify the installation:
sudo crontab -u apache -l
You should see three Magento cron entries running at different intervals. These jobs execute automatically without further configuration. Monitor cron execution in the logs:
tail -f /var/www/html/magento2/var/log/cron.log
If cron jobs fail, check file permissions and PHP configuration.
Step 12: Disable Two-Factor Authentication (Optional)
Magento 2.4.x includes mandatory two-factor authentication for admin access. For development environments, you may temporarily disable it:
sudo -u apache bin/magento module:disable Magento_TwoFactorAuth
sudo -u apache bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth
Recompile and flush cache:
sudo -u apache bin/magento setup:di:compile
sudo -u apache bin/magento cache:flush
For production environments, keep 2FA enabled for security. You can re-enable modules using the module:enable
command.
Step 13: Access Magento Admin Panel
Open your web browser and navigate to your admin URL:
http://yourdomain.com/admin_1a2b3c
Replace the random suffix with your actual admin URI. Log in using the admin username and password you set during installation. The dashboard displays sales statistics, recent orders, search terms, and system notifications. Explore key sections including Catalog for managing products and categories, Sales for viewing orders and invoices, Customers for managing customer accounts, Marketing for promotions and SEO, Content for CMS pages and blocks, and Stores for configuration settings.
For enhanced security, change the default admin URL to something unique:
sudo -u apache bin/magento setup:config:set --backend-frontname="customadminpath"
Replace “customadminpath” with your chosen URL segment.
Step 14: Security Hardening Best Practices
Strengthen your Magento installation with these security measures. Install an SSL certificate using Let’s Encrypt:
sudo dnf install certbot python3-certbot-apache -y
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
Certbot automatically configures HTTPS. Configure your firewall more restrictively:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
Edit PHP configuration to disable dangerous functions:
sudo nano /etc/php.ini
Find disable_functions
and add:
disable_functions = exec,passthru,shell_exec,system,proc_open,popen
Hide PHP version information by setting:
expose_php = Off
Implement fail2ban to prevent brute force attacks:
sudo dnf install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
Regularly update Magento and all system packages. Implement automated backups for your database and files.
Step 15: Performance Optimization Tips
Optimize Magento performance with these configurations. Enable full-page caching in Stores > Configuration > Advanced > System > Full Page Cache. Consider installing Varnish for even better caching. Install Redis for session and cache storage:
sudo dnf install redis -y
sudo systemctl start redis
sudo systemctl enable redis
Configure Magento to use Redis by editing app/etc/env.php
. Enable flat catalog for categories and products in Stores > Configuration > Catalog > Catalog > Storefront. Merge JavaScript and CSS files in Stores > Configuration > Advanced > Developer. Enable JavaScript bundling for faster page loads. Optimize images before uploading and enable lazy loading. Configure asynchronous indexing to prevent performance degradation during reindexing. Regularly clean old logs and session data.
Troubleshooting Common Installation Issues
OpenSearch connection failures typically indicate incorrect host or port settings. Verify OpenSearch is running with sudo systemctl status opensearch
and check the port with curl http://localhost:9200
. PHP memory limit errors require increasing the memory_limit
in php.ini to at least 2048M. Permission denied errors usually mean incorrect file ownership; run sudo chown -R apache:apache /var/www/html/magento2
to fix them.
Composer authentication failures occur when Magento Marketplace keys are incorrect or missing. Regenerate keys in your Magento Marketplace account and update auth.json. Database connection errors indicate wrong credentials in the installation command; verify database name, username, and password. Missing PHP extensions prevent installation; use php -m
to list installed modules and install any missing ones with DNF.
Apache rewrite module issues cause routing problems. Enable it with sudo a2enmod rewrite
or verify it’s loaded in Apache configuration. Admin panel 404 errors usually mean the wrong admin URI; check the installation output for the correct path. Blank pages or 500 errors indicate PHP errors; check /var/log/httpd/error_log
and /var/www/html/magento2/var/log/system.log
for details.
Static content deployment failures often relate to permissions. Ensure Apache owns all Magento files and directories have proper write permissions. Cache clearing problems may require manually deleting contents of var/cache
and var/page_cache
directories. Port conflicts occur when another service uses ports 80, 443, or 9200; use sudo netstat -tulpn
to identify conflicts.
Congratulations! You have successfully installed Magento. Thanks for using this tutorial for installing the Magento eCommerce Marketing Platform on your Fedora 42 Linux system. For additional help or useful information, we recommend you check the official Magento website.