How to Install Magento 2 on Debian 11 (Open Source Tutorial). This article will introduce what Magento is with it’s features, then Magento 2 new features and then we will start installing it on Debian 11. Let’s start!
What is Magento
Magento is one of the most popular eCommerce platforms written in PHP which helps programmers create eCommerce websites. Magento offers powerful marketing, search engine optimization, and catalog management tools as well as control over the look, content and functionality of their online store. Magento allows you to host an online store with only a few products and easily expand to tens of thousands of products without changing platforms. It offers a user friendly control panel and a variety of plug-ins and themes to enhance a customer’s experience.
Install Magento 2 on Debian 11 (Open Source Tutorial)
Install Apache, MariaDB, and PHP
Magento 2 requires an Apache web server, MariaDB database and PHP to be installed on your server. If not installed, you can install all of them by running the following command:
Magento uses a MariaDB or MySQL as a database backend. So you will need to create a database and user for Magento. First, connect to the MySQL shell with the following command:
mysql
Once you are logged in, create a database and user for Magento with the following command:
mysql> CREATE DATABASE magentodb;
mysql> CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'password';
Next, grant all the privileges to the Magento with the following command:
mysql> GRANT ALL PRIVILEGES ON magentodb.* TO 'magentouser'@'localhost';
Next, flush the privileges and exit from the MySQL with the following command:
First, you will need to install Composer on your system. You can install it by running the following command:
curl -sS https://getcomposer.org/installer | php
You should see the following output:
All settings correct for using Composer
Downloading...
Composer (version 2.3.5) successfully installed to: /root/composer.phar
Use it: php composer.phar
Next, move the Composer binary to the system location with the following command:
mv composer.phar /usr/local/bin/composer
Next, change the directory to the Apache web root and download the latest version of Magento:
cd /var/www/html/
wget https://github.com/magento/magento2/archive/refs/tags/2.4.2.zip
Once Magento 2 is downloaded, unzip the downloaded file with the following command:
unzip 2.4.2.zip
Move the extracted directory to the Apache web root directory:
mv magento2-2.4.2 /var/www/html/magento2
Next, change the directory to magento2 then update the composer and install all required dependencies with the following command:
cd magento2
composer update
composer install
Once all the dependencies are installed, set proper permission and ownership to magento2 directory:
chown -R www-data:www-data /var/www/html/magento2
chmod -R 755 /var/www/html/magento2
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chmod u+x bin/magento
Magento web installation wizard has been removed since version 2.3.7 so you will need to perform the Magento 2 installation from the command line interface.
First, change the directory to Magento2 with the following command:
cd /var/www/html/magento2/
Now, run the following command to start the installation:
Now, open your web browser and access the Magento 2 admin interface using the URL http://magento.example.com/admin_9lxo7k. You should see the Magento 2 login page:
Provide your Magento 2 admin username, password and click on the Sign in button. Once you are logged in, you should see the Magento 2 dashboard on the following page:
How to Install Magento 2 on Debian 11 (Open Source Tutorial) Conclusion
In this post, we explained how to install Magento 2 on Debian 11. You can now host your own eCommerce store using the Magento platform. For more information, visit the Magento 2 official documentation.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.