How to Install Magento on CentOS 8

Install Magento on CentOS 8

In this article, we will have explained the necessary steps to install and configure Magento on CentOS 8. 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 a free, open-source, and cloud-based e-commerce platform written in PHP. Magento gives a neighborhood and an advertisement edition of its platform – the neighborhood version is unfastened and is designed above all for people and/or small businesses. On the other hand, the firm edition is mainly aimed toward medium to giant companies and more of an enterprise environment. Magento is incredibly effortless and is wholly customizable, enabling you to create and customize online stores in mere minutes. On the desirable of the ideal customization, Magento gives strong marketing, seek engine optimization, and catalog-management tools. It lets you run numerous shops on an equal time and manage them using one panel.

Install Magento on CentOS 8

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

sudo dnf update

Step 2. Install LAMP stack on CentOS server.

It is assumed that you have already installed the LAMP stack on CentOS 8. If not, please check out the following tutorial:

Step 3. Download and Install Magento on the Ubuntu system.

We are downloading the latest version of Magento from the official page, You have to create an account on the Magento site to download Magento. So, the following screen will appear before download. Create an account or log in to your existing account to start the download process.

cd Downloads
mkdir /var/www/html/magento
cp Magento-CE-2.4.1-2020-01-07-02-12-12.tar.gz /var/www/html/magento

Go to the Magento folder and unzip the Magento installer:

cd /var/www/html/magento
tar xzvf Magento-CE-2.4.1-2020-01-07-02-12-12.tar.gz /var/www/html/magento

Set the directory permissions:

sudo chown -R apache:apache /var/www/html/magento

Step 4. Creating a MariaDB database for Magento.

Magento uses the MariaDB database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MariaDB server with the following command and enter your MariaDB root password:

mysql -u root -p

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

MariaDB > create database magento;
MariaDB > create user magentouser@localhost identified by 'your--strong--passwd';
MariaDB > grant all privileges on magento.* to magentouser@localhost identified by 'your-passwd';
MariaDB > flush privileges;
MariaDB > exit;

Step 5. Configure Apache.

Now configure Apache server to host Magento. Create a configuration file with an Alias to Magento directory:

sudo nano /etc/httpd/conf.d/magento.conf

Add below lines:

Alias /magento"/var/www/html/magento"<Directory /var/www/html/magento>  Options +FollowSymlinks  AllowOverride All<IfModule mod_dav.c>  Dav off</IfModule>SetEnv HOME /var/www/html/magentoSetEnv HTTP_HOME /var/www/html/magento</Directory>

Save the file and close it. Now, restart the Apache service to reload changes:

sudo systemctl restart httpd

Step 6. Configure Firewall.

To allow external users to access Magento from your server, you need to open the webserver port 80:

sudo firewall-cmd --add-port=80/tcp --zone=public --permanent
sudo firewall-cmd --reload

Step 7. Completing the Magento Installation.

In the last step of this guide, we need to access the Magento Web Interface and finish the installation. To finish the installation, open your browser and navigate to:

http://your_ip_address/magento

That’s all you need to do to install Magento on CentOS 8. I hope you find this quick tip helpful. For further reading on Magento, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.