• Email: [email protected]
  • Dedicated Server Login
  • About
  • 9288041031
  • Knowledge Base
  • Support
India's best web hosting | Ehostpiya India
  • Home
  • Hosting
    Web Hosting Quality Hosting Starting at ₹60/mo
    Cloud VPS Starting at ₹300/mo
    Dedicated Server First Starting at ₹2401/mo
    Reseller Web Hosting Conveniently Starting at ₹421/mo
    Application For Hosting
    • iconWordPress Hosting
    • iconJoomla Hosting
    • iconMagento Hosting
    • iconOpencart Hosting
    • iconPrestashop Hosting
    • iconDrupal Hosting
  • Email
  • Domain
  • SVG
    Contact Us Face any problem contact with us
    SVG
    About Us We are leading hosting company
  • My Account
Web Hosting Blogs by Ehostpiya | Tips and Tricks Web Hosting Blogs by Ehostpiya | Tips and Tricks
Buy Now

Archives

  • October 2026
  • September 2026
  • August 2026
  • October 2023

Categories

  • Control Panels
  • Magento
  • Miscellaneous
  • SEO
  • Technology
  • Trends
  • Web Hosting
  • Wordpress
Facebook Twitter Instagram Pinterest
Home How to Install Magento on a Linux Server: Complete Step-by-Step Guide
ByVandeeta
October 3, 2026

How to Install Magento on a Linux Server: Complete Step-by-Step Guide

Table of Contents

Toggle
  • How to Install Magento on a Linux Server: Complete Step-by-Step Guide
    • What You Need Before Installing Magento
  • Step 1: Update the Linux Server
  • Step 2: Install Basic Server Utilities
  • Step 3: Install the Required PHP Version
      • Why PHP Compatibility Matters
  • Step 4: Install MySQL
  • Step 5: Create a Magento Database
  • Step 6: Install Composer
  • Step 7: Create the Magento Directory
  • Step 8: Configure Magento Authentication Keys
  • Step 9: Download Magento Using Composer
  • Step 10: Configure Magento File Permissions
  • Step 11: Configure PHP Settings
  • Step 12: Configure Nginx or Apache
    • Nginx
    • Apache
  • Step 13: Install and Configure OpenSearch or Elasticsearch
  • Step 14: Run the Magento Installation Command
      • Important
  • Step 15: Configure Magento Cron
  • Step 16: Set Magento to Production Mode
  • Step 17: Run Magento Indexers
  • Step 18: Flush Magento Cache
  • Step 19: Configure SSL
  • Step 20: Test Your Magento Store
  • Common Magento Installation Problems
    • 1. Composer Authentication Error
    • 2. PHP Version Error
    • 3. Memory Limit Error
    • 4. Permission Errors
    • 5. Search Engine Connection Error
    • 6. 404 Errors
  • Magento Installation Checklist
  • Final Thoughts

How to Install Magento on a Linux Server: Complete Step-by-Step Guide

Magento is a powerful eCommerce platform for building online stores with advanced catalog, checkout, payment, inventory, and customization capabilities. Unlike hosted eCommerce platforms, Magento can be installed on your own Linux server, giving you greater control over the hosting environment.

However, Magento requires several server-side components, including PHP, a supported database, Composer, a web server, a search engine, and appropriate PHP extensions.

This guide explains how to install Magento Open Source on a Linux server from start to finish.

Important: Magento requirements vary by release. Before starting, verify that the PHP, database, OpenSearch/Elasticsearch, Composer, and other versions in this guide are compatible with the exact Magento release you intend to install.

What You Need Before Installing Magento

Before beginning, make sure you have:

  • A Linux VPS or dedicated server
  • Root or sudo access
  • A domain name
  • A supported PHP version
  • MySQL or another supported database
  • Apache or Nginx
  • Composer
  • OpenSearch or Elasticsearch, depending on the Magento release
  • SSL certificate
  • Sufficient RAM and storage
  • A Magento authentication key pair

Magento authentication keys are used by Composer to access Magento packages. You can obtain them through your Magento/Adobe account.


Step 1: Update the Linux Server

Start by updating the operating system.

For Ubuntu or Debian-based systems:

sudo apt update
sudo apt upgrade -y

For RHEL-based distributions, use the appropriate package manager for your operating system.

After updating, reboot if the system recommends it:

sudo reboot

Reconnect to the server after it has restarted.


Step 2: Install Basic Server Utilities

Install commonly required utilities:

sudo apt install -y curl wget unzip git vim ca-certificates

You may also need additional packages depending on your Magento version and chosen web server.


Step 3: Install the Required PHP Version

Magento requires a specific PHP version depending on the release.

Check the currently installed version:

php -v

If PHP isn’t installed, install the version supported by your Magento release.

For example, on a supported Ubuntu environment, you may install PHP and common extensions with:

sudo apt install -y php php-cli php-fpm php-mysql php-curl php-gd \
php-intl php-mbstring php-xml php-zip php-bcmath php-soap

Then verify:

php -v

And:

php -m

Why PHP Compatibility Matters

Installing a PHP version that Magento does not support can result in:

  • Installation failures
  • Composer dependency errors
  • Runtime errors
  • Extension compatibility problems
  • Unexpected application behavior

Always check the requirements for your exact Magento release before installing PHP.


Step 4: Install MySQL

Magento requires a supported database.

Install MySQL:

sudo apt install -y mysql-server

Start the service:

sudo systemctl enable --now mysql

Check its status:

sudo systemctl status mysql

Then run the security configuration:

sudo mysql_secure_installation

Follow the prompts to configure your MySQL installation securely.


Step 5: Create a Magento Database

Log in to MySQL:

sudo mysql

Create a database:

CREATE DATABASE magento;

Create a database user:

CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';

Grant privileges:

GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost';

Apply the privileges:

FLUSH PRIVILEGES;

Exit MySQL:

EXIT;

Keep the database name, username, and password available because you will need them during Magento installation.


Step 6: Install Composer

Composer manages Magento’s PHP dependencies.

Download the Composer installer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Install Composer globally:

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Remove the installer:

rm composer-setup.php

Check the installation:

composer --version

Use a Composer version supported by your Magento release.


Step 7: Create the Magento Directory

Create a directory for the website:

sudo mkdir -p /var/www/magento

Change ownership:

sudo chown -R $USER:$USER /var/www/magento

Move into the directory:

cd /var/www/magento

Step 8: Configure Magento Authentication Keys

Magento packages are distributed through the Magento Composer repository.

You need authentication keys to install Magento.

When Composer asks for credentials:

  • Username: Your Magento public key
  • Password: Your Magento private key

You can obtain these credentials from your Magento account.

Do not publish your private authentication key or store it in publicly accessible files.


Step 9: Download Magento Using Composer

From the Magento directory, use Composer to create the project.

The exact package and version depend on the Magento release you want to install.

A typical command looks like:

composer create-project --repository-url=https://repo.magento.com/ \
magento/project-community-edition .

Composer will download Magento and its dependencies.

The process can take several minutes depending on your server and network connection.


Step 10: Configure Magento File Permissions

Magento needs appropriate permissions for its application files.

A common ownership configuration is:

sudo chown -R www-data:www-data /var/www/magento

The exact web-server user depends on your Linux distribution and web server configuration.

For Ubuntu with Apache or Nginx, www-data is commonly used.

Avoid using:

chmod -R 777

as a solution for permission problems. Overly permissive permissions can create security risks.


Step 11: Configure PHP Settings

Magento may require PHP configuration changes depending on the version and workload.

Edit the appropriate PHP configuration file:

sudo nano /etc/php/*/fpm/php.ini

Common settings that may need adjustment include:

memory_limit = 2G
max_execution_time = 1800
max_input_time = 1800
upload_max_filesize = 64M
post_max_size = 64M

The exact recommended values depend on the Magento release and workload.

After changing PHP-FPM settings, restart PHP-FPM:

sudo systemctl restart php*-fpm

Step 12: Configure Nginx or Apache

Magento requires a properly configured web server.

Nginx

Create a virtual host configuration for your domain.

For example:

server {
    listen 80;
    server_name example.com www.example.com;

    set $MAGE_ROOT /var/www/magento;
    set $MAGE_MODE production;

    include /var/www/magento/nginx.conf.sample;
}

The actual configuration should be adapted to your Magento version and server setup.

Enable the configuration and reload Nginx:

sudo nginx -t
sudo systemctl reload nginx

Apache

If using Apache, enable the necessary modules and configure a virtual host pointing to Magento’s pub directory.

A simplified example is:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/magento/pub

    <Directory /var/www/magento/pub>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Then test the configuration:

sudo apachectl configtest

Restart Apache:

sudo systemctl restart apache2

Magento’s pub directory should be used as the web-accessible document root rather than exposing the entire Magento installation.


Step 13: Install and Configure OpenSearch or Elasticsearch

Magento’s search functionality requires a compatible search engine.

Depending on your Magento version, you may need OpenSearch or Elasticsearch.

Check the requirements for your specific Magento release before installing either one.

After installing the supported search service, verify that it is running.

For example:

sudo systemctl status opensearch

You should also test the service locally:

curl http://127.0.0.1:9200

The exact configuration depends on the supported search engine and Magento release.


Step 14: Run the Magento Installation Command

Once the server, database, PHP, web server, and search engine are ready, run the Magento installer.

A typical command looks like:

php bin/magento setup:install \
--base-url=https://example.com/ \
--db-host=localhost \
--db-name=magento \
--db-user=magento_user \
--db-password='StrongPasswordHere' \
--admin-firstname=Admin \
--admin-lastname=User \
[email protected] \
--admin-user=admin \
--admin-password='StrongAdminPasswordHere' \
--language=en_US \
--currency=USD \
--timezone=Asia/Kolkata \
--use-rewrites=1

Replace the example values with your actual configuration.

Important

Use a strong administrator password and avoid publishing installation commands containing real database or administrator credentials.

The exact installer options can vary between Magento versions, so check the documentation for your specific release if an option has changed.


Step 15: Configure Magento Cron

Magento uses cron jobs for many background operations.

From the Magento directory, run:

php bin/magento cron:install

Verify the cron configuration:

crontab -l

You should see Magento-related cron entries.

Cron handles background operations such as indexing and scheduled tasks.


Step 16: Set Magento to Production Mode

For a production website, Magento should normally run in production mode.

Check the current mode:

php bin/magento deploy:mode:show

Set production mode:

php bin/magento deploy:mode:set production

Production mode is intended for live environments and provides a configuration optimized for production operation.


Step 17: Run Magento Indexers

Magento uses indexes to improve the performance of catalog and other operations.

Run:

php bin/magento indexer:reindex

Check indexer status:

php bin/magento indexer:status

If an indexer requires updating, configure Magento’s cron and indexing strategy appropriately.


Step 18: Flush Magento Cache

Clear the Magento cache:

php bin/magento cache:flush

Check cache status:

php bin/magento cache:status

You can enable disabled caches with:

php bin/magento cache:enable

Step 19: Configure SSL

An eCommerce store should use HTTPS.

If you are using Let’s Encrypt, Certbot can be used on supported Linux distributions.

For example:

sudo apt install certbot python3-certbot-nginx

Then:

sudo certbot --nginx -d example.com -d www.example.com

If using Apache, use the appropriate Certbot Apache package and command.

After enabling SSL, make sure Magento’s base URLs use HTTPS.


Step 20: Test Your Magento Store

Open your domain in a browser:

https://example.com

Then access the Magento administration area using the administrator URL configured during installation.

Test:

  • Homepage
  • Product pages
  • Categories
  • Search
  • Customer registration
  • Login
  • Shopping cart
  • Checkout
  • Payment method
  • Shipping method
  • Order placement
  • Transaction emails
  • Admin dashboard

Testing the complete purchase process before launch is essential.


Common Magento Installation Problems

1. Composer Authentication Error

If Composer reports authentication problems, check that you are using valid Magento authentication keys.

Make sure the keys are associated with an account that has the required access.


2. PHP Version Error

If Magento reports that your PHP version is unsupported, install a PHP version compatible with your Magento release.

Check:

php -v

Also remember that CLI PHP and PHP-FPM can use different configurations.


3. Memory Limit Error

If Composer or Magento runs out of memory, check:

php -i | grep memory_limit

Increase the memory limit where appropriate and ensure the server itself has sufficient RAM.


4. Permission Errors

Incorrect ownership or permissions can cause errors involving:

  • var
  • generated
  • pub/static
  • pub/media

Check the ownership and permissions of the Magento installation.

Avoid solving these problems by assigning 777 permissions to the entire Magento directory.


5. Search Engine Connection Error

If Magento cannot connect to OpenSearch or Elasticsearch, verify:

sudo systemctl status opensearch

Then test:

curl http://127.0.0.1:9200

Also verify that the search engine version is compatible with your Magento release.


6. 404 Errors

If Magento pages return 404 errors, check:

  • Web-server configuration
  • URL rewrites
  • Magento base URL
  • Document root
  • Nginx/Apache configuration
  • File permissions

For Apache, ensure the required rewrite functionality is enabled.


Magento Installation Checklist

Before considering the installation complete, verify:

  • Linux server is updated
  • Supported PHP version installed
  • Required PHP extensions installed
  • Supported database configured
  • Composer installed
  • Magento authentication keys configured
  • Magento downloaded successfully
  • Correct file ownership configured
  • Nginx or Apache configured
  • Supported OpenSearch/Elasticsearch configured
  • Magento database created
  • Magento installation completed
  • Cron configured
  • Indexers working
  • Cache enabled
  • HTTPS enabled
  • Admin login tested
  • Checkout tested
  • Backups configured

Final Thoughts

Installing Magento on a Linux server requires more preparation than installing a simple PHP website because Magento depends on several services working together. PHP, the database, Composer, the web server, search engine, cron, caching, permissions, and SSL must all be configured correctly.

The most important step is to start with the exact Magento version you plan to install and verify its official system requirements before choosing PHP, database, and search-engine versions.

Once the base installation is working, focus on security, caching, backups, monitoring, and performance before opening the store to customers.

ByVandeeta
Updated October 03, 2026
  • Magento

Read Next

ByVandeeta
October 3, 2026

How to Install Magento Using SSH?

Below is a complete, SEO-friendly tutorial you can publish on your hosting blog. How to Install Magento Using…
  • Magento
ByVandeeta
October 3, 2026

How to Configure Magento After Installation: Complete Step-by-Step Guide

How to Configure Magento After Installation: Complete Step-by-Step Guide Installing Magento is only the first step in launching…
  • Magento
ByVandeeta
October 3, 2026

How to Access the Magento Admin Panel?

How to Access the Magento Admin Panel The Magento Admin Panel is the central control area for managing…
  • Magento

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Explore Categories

  • Control Panels 7
  • Magento 52
  • Miscellaneous 5
  • SEO 17
  • Technology 10
  • Trends 9
  • Web Hosting 7
  • Wordpress 100

Recent Posts

  • How to Fix WordPress “Too Many Redirects”
  • How to Fix WordPress Critical Error
  • How to Fix WordPress Database Connection Error
  • How to Fix WordPress White Screen of Death
  • How to Fix WordPress 404 Error

Recent Comments

  1. Tabias H. on The Future is 5G: Understanding the Next Wave of Connectivity
  2. Elliot Alderson on Evolving Workspaces: The Rise of the Hybrid Work Trend
  3. James Mann on Evolving Workspaces: The Rise of the Hybrid Work Trend
Swyft

Welcome to the Ehostpiya Blog, your trusted resource for web hosting, WordPress, VPS, domains, website security, and online business tips.

Our goal is to make web hosting and website management easier to understand for everyone—from beginners launching their first website to experienced developers and business owners. We publish practical guides, hosting tips, tutorials, and helpful insights to help you build, manage, and grow your website successfully.

At Ehostpiya, we believe that reliable information and quality hosting go hand in hand. Explore our latest articles and discover simple solutions for a faster, safer, and more successful online presence.

  • Facebook
  • Twitter
  • Instagram
  • Pinteres

Featured Posts

  • AI and Ethics: Navigating the Complex Landscape of Artificial Intelligence
    by Vandeeta
    October 11, 2023
  • AR and VR: Blurring the Lines Between Reality and Virtuality
    by Vandeeta
    October 11, 2023
  • Best WordPress Caching Plugins to Improve Website Speed
    by Vandeeta
    September 26, 2026
  • Blockchain Unchained: How Distributed Ledger Technology is Transforming Industries
    by Vandeeta
    October 11, 2023

Web Hosting Discount

cLAIM NOW
logo

Ehostpiya is reliable Web hosting provider, with aim to provide affordable Website and application hosting to various clients for their online business and presence.

Hosting
  • Web Hosting
  • Cloud VPS
  • Reseller Hosting
  • Email Hosting
  • Dedicated Server
  • Nodejs Hosting
  • SSL Certificate
Legal
  • Accepted Uses Policy
  • privacy Policy
  • Terms of Service
  • Refund and cancellation
  • Service Delivery Policy
Company
  • About Us
  • Our Clients
  • Contact Us
  • Our Blog
Support & Tools
  • Open Support Request
  • View Ticket
  • Knowledge Base
  • Report Abuse
  • check nameserver
  • What is my IP
  • Mx lookup

© Ehostpiya, All rights reserved

  • Terms & Condition
  • Privacy Policy