How to install Magento Open Source on Debian Latest

In this tutorial, we will guide you through the process of installing Magento Open Source on Debian Latest version. We will be using the official Magento 2 repository from https://github.com/magento/magento2.

Prerequisites

Before we start the installation process, make sure the following requirements are met:

Step 1: Clone Magento 2 repository

In this step, we will clone the official Magento 2 repository from GitHub.

  1. Open up your terminal window and run the following command:
$ git clone https://github.com/magento/magento2.git
  1. Once the cloning process is finished, change the current directory to the Magento 2 directory using the following command:
$ cd magento2

Step 2: Install Composer

Composer is a dependency manager for PHP that will help us manage Magento 2 dependencies. In this step, we will install Composer on our system.

  1. Run the following commands to download and install the Composer:
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
  1. Verify that the installation is done by running the following command:
$ composer --version

Step 3: Install Magento 2

In this step, we will install Magento 2.

  1. Run the following command to install the Magento 2:
$ composer install
  1. After the installation is complete, the following message will be displayed:
[SUCCESS] Magento installation complete.
  1. Next, you need to generate an SSH key that Magento uses to communicate with the Magento Marketplace. Use the following command to generate the key:
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. Press Enter when asked for the file name and directory.

  2. After the SSH key is generated, copy it using the following command:

$ cat ~/.ssh/id_rsa.pub
  1. Copy the output of this command.

  2. Sign in to the Magento Marketplace and go to the Access Keys page.

  3. Click on the Create A New Access Key button.

  4. Enter a name for the new key and paste the SSH key.

  5. Click on the Generate Key button.

  6. Copy the public key and the private key.

  7. Run the following command inside the Magento 2 directory to add the Magento Marketplace credentials:

$ composer config --global http-basic.repo.magento.com <your-public-key> <your-private-key>
  1. Replace <your-public-key> and <your-private-key> with the keys you copied from the Magento Marketplace.

  2. After adding the credentials, run the following commands:

$ bin/magento setup:install --base-url=http://localhost/ --db-host=localhost --db-name=magento2 --db-user=root --db-password=<root-password> --admin-firstname=admin --admin-lastname=admin --admin-email=admin@example.com --admin-user=admin --admin-password=<admin-password> --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
  1. Replace <root-password> and <admin-password> with your own passwords.

  2. After the installation is finished, you should see the following message:

[SUCCESS] Magento installation complete.

Step 4: Configure Apache or Nginx

In this step, we will configure Apache or Nginx to serve the Magento site.

Apache

  1. Run the following command to enable the Apache rewrite module:
$ sudo a2enmod rewrite
  1. Add the following content to the <VirtualHost> section of your Apache configuration:
<Directory /var/www/html/magento2>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
  1. Restart Apache:
$ sudo systemctl restart apache2

Nginx

  1. Add the following content to your Nginx configuration:
location /magento2 {
    try_files $uri $uri/ /magento2/index.php$is_args$args;
    location ~ ^/magento2/(index|get|static|report|404|503|health_check)\.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param MAGE_MODE developer;
        include fastcgi_params;
    }
}
  1. Restart Nginx:
$ sudo systemctl restart nginx

Step 5: Access Magento 2

In your web browser, go to http://localhost/magento2 to access your Magento 2 installation.

Congratulations, you have successfully installed Magento 2 on Debian Latest version!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!