How to Install Magento: A Step-by-Step Guide

Magento is a powerful open-source eCommerce platform that offers flexibility and scalability for online stores. This guide will walk you through installing Magento on a local server or a live web server.

Prerequisites

Before installing Magento, ensure you have the following:

  • Server Requirements:
    • Apache 2.4 or Nginx 1.x
    • MySQL 8.0
    • PHP 8.1 or 8.2
    • Composer (for dependencies)
  • Recommended Hosting:
    • A VPS or Dedicated Server (for better performance)
    • A domain name (if deploying live)
    • SSL Certificate (for HTTPS)

Step 1: Download Magento

Magento can be installed via Composer. Use the following command:

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

This command will download Magento to the magento directory.

Authentication

You will be prompted to enter your Magento Marketplace authentication keys. You can get these from:

Step 2: Configure File Permissions

Set proper file permissions to avoid installation errors:

bashCopyEditcd magento
find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} +
find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} +

Step 3: Create a Database

Login to MySQL and create a database:

sqlCopyEditCREATE DATABASE magento;
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
EXIT;

Step 4: Install Magento

Run the installation command:

bashCopyEditphp bin/magento setup:install \
--base-url="http://localhost/magento" \
--db-host="localhost" \
--db-name="magento" \
--db-user="magento_user" \
--db-password="your_password" \
--admin-firstname="Admin" \
--admin-lastname="User" \
--admin-email="admin@example.com" \
--admin-user="admin" \
--admin-password="Admin123" \
--language="en_US" \
--currency="USD" \
--timezone="America/New_York" \
--cleanup-database \
--use-rewrites=1

Step 5: Set Up Permissions

After installation, run:

bashCopyEditchmod -R 777 var/ generated/ pub/

Step 6: Access Magento Admin

Once installed, Magento provides an admin panel URL. Visit:

arduinoCopyEdithttp://localhost/magento/admin

Log in with your admin credentials.

Step 7: Enable Development Mode (Optional)

For debugging, switch to developer mode:

bashCopyEditphp bin/magento deploy:mode:set developer

Conclusion

You have successfully installed Magento! Now, you can start customizing your store and adding products.

Post Comment