How to Install Magento on Debian 10

Install Magento on Debian 10

In this article, we will have explained the necessary steps to install Magento on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Magento is an open-source e-commerce platform written in PHP. It uses multiple other PHP frameworks such as Laminas and Symfony. The free open source edition comes with the performance and features to meet the requirements of the businesses of today. It is the perfect platform for growing small business sites or anyone who wishes to learn and experiment with building an online store.

Install Magento on Debian 10

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade
sudo apt install curl git

Step 2. Install LAMP Stack on Debian Linux.

Magento is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Debian up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Debian to serve PHP before you continue.

Step 3. Creating a MySQL database for Magento.

Magento uses the MySQL database to store all its data. Log in to your MySQL server with the following command and enter your MySQL root password:

mysql -u root -p

Once you’re in the MySQL console, create a new database:

MariaDB [(none)]> create database magento2;
MariaDB [(none)]> GRANT ALL ON magento2.* TO [email protected] IDENTIFIED BY 'magento';
MariaDB [(none)]> exit

Step 4. Install Magento on the Debian system.

Now run the following commands below to download and install Composer:

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

Regardless of the method used to download Magento packages, you will need to start by registering and logging into a Magento account.

cd /var/www/html
sudo composer create-project --repository= magento/project-community-edition magento2

After running the second command above, you’ll be prompted for a username and password. The username you enter should be the public key from the Magento Access Keys, and the password should be the private key.

Next, set the directory ownership of the directory to Apache user and change the permissions as indicated below:

cd /var/www/html/magento2
sudo bin/magento setup:install --base-url= --db-host=localhost --db-name=magento --db-user=magentoadmin --db-password=magentopassword --admin-firstname=Admin --admin-lastname=User [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

Step 5. Configuring Apache.

Now create a new virtual host configuration file for your Magento website, named magento.conf:

nano /etc/apache2/sites-available/magento.conf

And add the following content to the file:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/magento2/

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

     <Directory /var/www/html/magento2/>
            Options FollowSymlinks
            AllowOverride All
            Require all granted

Then, enable the new site with the following command:

sudo a2ensite magento.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

The next step is to set the permissions for the directories used by Magento using the following commands:

sudo chown -R www-data:www-data /var/www/html/magento2/
sudo chmod -R 755 /var/www/html/magento2/

Step 6. Completing the Magento Installation.

Once all of these are set up, you can continue in your web browser by opening your cloud server’s public IP or domain.

That’s all you need to do to install Magento on Debian 10 (Buster). I hope you find this quick tip helpful. For further reading on the Magento open-source e-commerce platform, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.