How to Install Magento 2 on a Local Server in 2025?

how to install magento 2 on a local server in 2025?

How to Install Magento 2 on a Local Server in 2025

Are you looking to set up Magento 2 on a local server in 2025? Whether you're a developer, a business owner, or someone who wants to test Magento before deploying it on a production server, this guide will walk you through the step-by-step process of installing Magento 2 locally.

Before beginning, ensure you have the necessary system requirements and prerequisites installed.

Prerequisites

  • Operating System: Windows, macOS, or Linux
  • Web Server: Apache 2.4 or later, or Nginx 1.8 or later
  • PHP: 8.1 or later
  • Database: MySQL 8.0 or MariaDB 10.4 or later
  • Composer: Latest version
  • Node.js: Latest LTS version
  • Varnish Cache: 6.x (Optional but recommended)
  • Elasticsearch: 7.6 or later

Step-by-Step Installation Guide

Step 1: Set Up Your Environment

Before installing Magento 2, ensure that PHP, MySQL or MariaDB, and a web server (Apache or Nginx) are properly set up on your machine. Confirm that all services are running and configured.

  1. Install PHP: Ensure you have PHP 8.1 or higher.
  2. Install Composer: Download and install the latest version of Composer from the official site.
  3. Set Up a Database: Use MySQL or MariaDB to create a new database for Magento 2.

Step 2: Download Magento 2

  1. Get Magento 2: Visit the official Magento Download Page and download Magento 2. Make sure to choose the latest version suitable for your environment.
  2. Extract Files: Unzip the Magento 2 package to your desired directory, which will be the root directory for your local web server.

Step 3: Install Magento 2

  1. Navigate to the Magento Root Directory: Open a terminal and navigate to the directory where you extracted Magento 2.

    cd /path/to/your/magento/directory
    
  2. Install Dependencies with Composer: Run the following Composer command to install required dependencies:

    composer install
    
  3. Set Permissions: Ensure that the necessary directories have the correct permissions.

    sudo chmod -R 755 .
    sudo chmod -R 777 var pub generated
    
  4. Run the Setup Wizard: Access the setup wizard in your web browser by visiting http://localhost/magento-setup.

    Follow the instructions provided by the setup wizard to complete the installation. You'll need to enter database information, admin account details, and configure web access settings.

Step 4: Verify Installation

After the installation is complete, you can access the Magento storefront and admin panel in your web browser:

  • Storefront: http://localhost/magento
  • Admin Panel: http://localhost/magento/admin

Additional Installation Tutorials

By following the above steps, you'll have a fully functioning Magento 2 setup on your local server ready for development or testing. Happy coding!