Magento 2 is a popular e-commerce platform that powers thousands of online stores around the world.
If you’re planning to set up an online store using Magento 2, you can do this easily on RunCloud.
In this article, we’ll guide you through the process of installing Magento 2, along with all of the necessary dependencies.
Let’s get started!
Before we start the installation process, it’s important to ensure that the system meets the minimum requirements for running Magento. This section will provide a list of requirements, and instructions for checking your system’s compatibility.
Magento 2.4.6 has the following requirements:
- Operating System: 64-bit Linux
- Web Server: Apache 2.4, Nginx 1.8
- PHP: 8.1 or 8.2 (along with the necessary PHP extensions)
- MySQL: 8.0
- Composer: 2.2
- Search and Analytics Engine: Elasticsearch 8.4, 7.17 or AWS OpenSearch 1.2
Installing The Necessary PHP Extensions
If you don’t have all of the necessary extensions, you can install them on your server by running the following command. Simply log in via SSH, copy the following command, and paste it into your terminal:
sudo apt-get install php-intl php-gd php-zip php-bcmath php-curl php-mysqlnd php-soap php-ctype php-dom php-fileinfo php-iconv php-json php-mbstring
Make sure you run the above command with superuser permissions. After running the command you will be asked whether you want to install the listed extensions – press ‘Y’ to continue with the installation.
Once done, you will need to reload the PHP-FPM service. You can do this by running the following commands:
systemctl reload php81rc-fpm
systemctl reload php82rc-fpm
We have covered this topic in more detail on our blog in a post titled How To Install Elasticsearch. However, if you are in a hurry, you can use the following commands to quickly install it. Just log into your server with the necessary privileges and run these commands:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
sudo apt-get install apt-transport-https
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
After the installation is complete, you can check if Elasticsearch is working as expected by running the following command:
You should get an output similar to the screenshot shown below:
Creating A Database
We recommend creating a separate database and user for Magento 2. RunCloud makes it easy to add and manage database users on your server. In this section, we’ll walk you through the process of creating a new database for your Magento 2 installation.
Open your RunCloud dashboard and locate the server that you want to use. In the “Databases” tab, look for the “Database Users” tab. Once you find it, click “Add New Database User” to create a new account. Provide the necessary login credentials, and then make sure you save it.
After creating the database user, go back to the “Databases” tab. Click on “Add New Database” and give it a suitable name. Don’t forget to grant access to the user that we just created.
After you have created the database, save it – and continue with the installation.
Downloading Magento 2
After you have completed all the prerequisites for Magento 2 we can proceed with the installation. Go to your RunCloud dashboard and create a new application. Pick an “Empty Web App”, and then fill in all the necessary details.
In the Basic settings and Stack section, add
/pub in the public path and don’t forget to use a supported version of PHP. At the time of writing, the latest version of Magento (2.4.6) supports only PHP 8.1 and PHP 8.2.
After your application has been created, you will need to log into your server to start the installation. The following commands need to be executed as the “Owner of the web application”, so make sure you are logged in as the correct user. In the above screenshot, the owner of the application is “runcloud”.
You can use the “whoami” command to find out the name of the current user. If you are logged in as a different user, you can use the “sudo su” command, followed by the name of the desired user to log into their account.
Once you have logged in successfully, use the “cd” command to navigate to the root directory of your project. If you are not sure what your root directory is, you can find it in the RunCloud dashboard.
In the project directory, you can use the following commands to remove the default index.html file and download the installation files for the Magento Community Edition.
rm -rf pub/
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
During the installation, you will be asked to provide a username and password for downloading the files. Although Magento is free, it was acquired by Adobe, and so you will now be required to have an Adobe account.
In this tutorial, we will only be using Magento, which is the free version of Adobe Commerce. To get your username and password, go to the Adobe Commerce Dashboard and log in with your Adobe credentials.
In the dashboard you can create a new access key free of charge. Once you have generated the key, enter the “Public Key” in the username field, and the “Private Key” in the password field. You should note that text entered in the password field is not displayed for security purposes, but all keystrokes are being recorded.
Installing Magento 2
With the system requirements met, files extracted, and database created, it’s time to start the Magento 2 installation process. To begin the installation, copy and paste the command below into a text editor and make the following changes:
- Add the base URL with the URL of your website
- Add the name of the database using the database that we created
- Add the username and password of the database user
- Configure the login information of the administrator user
- Set your preferred currency and timezone.
bin/magento setup:install \
--admin-last name=admin \
[email protected] \
After making the changes, you can run the above command in your terminal to begin the installation, which should take 5-6 minutes. If you follow all the steps correctly you will be greeted with the message below. You can then go to the URL of your website to visit your Magento store.
After the installation is finished, you can enable production mode using the following command.
bin/magento deploy:mode:set production
The above command will generate necessary static content for your website and enable several optimizations to serve content faster.
After Action Report
Installing Magento 2 might seem like a daunting task, but with this step-by-step guide you can set up your online store on RunCloud in no time. Once Magento 2 is installed, there are still a few post-installation steps you’ll need to take, such as verifying the installation, setting up the admin account, and configuring payment methods before you can start using your new online store. Refer to Adobe’s documentation to learn how to do this.
If you’re ready to take your server management to the next level, sign up for RunCloud today. RunCloud is the perfect solution for you if you’re looking to make managing your servers easier. So why wait? Sign up now and start enjoying the benefits of RunCloud today!