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.
- Install PHP: Ensure you have PHP 8.1 or higher.
- Install Composer: Download and install the latest version of Composer from the official site.
- Set Up a Database: Use MySQL or MariaDB to create a new database for Magento 2.
Step 2: Download Magento 2
- Get Magento 2: Visit the official Magento Download Page and download Magento 2. Make sure to choose the latest version suitable for your environment.
- 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
-
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
-
Install Dependencies with Composer: Run the following Composer command to install required dependencies:
composer install
-
Set Permissions: Ensure that the necessary directories have the correct permissions.
sudo chmod -R 755 . sudo chmod -R 777 var pub generated
-
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
- Magento Installation on AWS
- Magento Installation on Web Hosting
- Magento Installation on Cloud Hosting
- Magento Installation Tutorial on Linode
- Magento Installation on GoDaddy
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!