Magento 2.4 does not have a web-based installer and needs to be installed through the command line. Magento 2.4 also requires a running Elasticsearch 7 instance, as it no longer supports MySQL as a search engine, nor lower Elasticsearch versions. If your plan supports it, you can install and run Elasticsearch locally as a WebApp. Instructions are available in the following article: How to install and run Elasticsearch as a WebApp.

If you would like to configure Elasticsearch later, the Elasticsearch modules need to be disabled before Magento is installed. In this guide, we will disable the Elasticsearch modules before we install Magento. This will allow you to install Magento and develop your online store without Elasticsearch.

Keep in mind that disabling the Elasticsearch modules will cause the search function in your Magento store to stop working.

In order for this guide to work, you will need to download the Magento installation package without sample data. Installing the package with sample data requires Elasticsearch to be available for the installation to complete.

You need to follow these steps to install Magento 2.4: 

1. Download the installation files from the site of the vendor.

Magento can be obtained from: 

https://magento.com/tech-resources/download

There, click on the "Get it" button under the Archive heading, select your Build version and Format, and click on the Download button. 



2. Upload the installation files to your hosting space.

Once you have downloaded the archive that contains the installation files, you need to upload it to your hosting space. 

You can either extract all files from the downloaded archive and upload them, or you can upload the archive and use the hosting Control Panel's File Manager to extract the package. 

The best way to upload big files or multiple files is via FTP. If you are not sure how to upload the files, please check our instructions on how to upload files.

In order to install Magento, the installation directory needs to be completely empty. If there are any files in the directory, you can either delete them via FTP, or through your web hosting Control Panel's File Manager

3. Create a database and a database user.

You need to create a MySQL database for the Magento application. You can do this through your web hosting Control Panel's MySQL Databases section. It is recommended that you create the database with the utf8mb4_general_ci collation.



You also need to create a MySQL user for Magento. You can create it from the MySQL Databases section > MySQL users tab of your Control Panel. Be sure to grant all privileges to the MySQL user.

Save the name of the MySQL database, the MySQL user, and the MySQL password for later (e.g. you can write the MySQL credentials in a temporary text file on your computer).



4. Set the correct PHP version.

Magento 2.4 requires PHP 7.4 or a newer version. You can check the PHP version used by your domain/subdomain through the hosting Control Panel > PHP Settings section. Changing the PHP version is covered in the PHP Version article.

5. Log in to your account over SSH.

Log in to your account over SSH. Logging in over SSH is covered in the SSH section in our documentation. Then, navigate to the directory that contains the extracted Magento installation files. You can do this by running the following command (make sure you replace the path in the command with the actual path to your installation):

cd /path/to/your/magento/installation/dir

6. Run the installation script.

Run the installation script by executing the following command:

php bin/magento setup:install --base-url=http://yourdomain.com/magento/ --db-host=db_host --db-name=username_database --db-user=db_username --db-password=db_password --admin-firstname=Your_first_name --admin-lastname=Your_last_name --admin-email=youremail@yourdomain.com --admin-user=adminusername --admin-password=adminpassword --language=en_US --currency=CUR --timezone=Continent/City --use-rewrites=1

In this command, each of the options should be set as follows:

--base-url - The URL where your Magento installation will be accessible.
--db-host - The database host where Magento should connect to the database at. Leave this set to localhost for MySQL 5, or set it as 127.0.0.1:3308 for MySQL 8.
--db-name - The name of the database you created for your Magento installation at step 3.
--db-user - The username of the database user you created for your Magento installation at step 3.
--db-password - The password for the database user you created for your Magento installation at step 3.
--admin-firstname - The first name of the administrator of your Magento installation.
--admin-lastname - The last name of the administrator of your Magento installation.
--admin-email - The email address of the administrator of your Magento installation.
--admin-user - The username of the administrator of your Magento installation.
--admin-password - The password for the administrator username of your Magento installation.
--language - The language code of your Magento installation. The full list of the languages supported by Magento can be obtained by running the following command in the Magento installation directory:
php bin/magento info:language:list--currency The currency code of your Magento installation. The full list of the currencies supported by Magento can be obtained by running the following command in the Magento installation directory:
php bin/magento info:currency:list--timezone - The time zone code of your Magento installation. The full list of the time zones supported by Magento can be obtained by running the following command in the Magento installation directory:
php bin/magento info:timezone:list--use-rewrites - Leave this option set to 1.

Attention

If you have an Elasticsearch service running locally, you need to add the following option to the installation command:

--elasticsearch-port=XXXX - You need to replace XXXX with the actual port Elasticsearch is listening on. The final command should look like this:

php bin/magento setup:install --base-url=http://yourdomain.com/magento/ --db-host=db_host --db-name=username_database --db-user=db_username --db-password=db_password --admin-firstname=Your_first_name --admin-lastname=Your_last_name --admin-email=youremail@yourdomain.com --admin-user=adminusername --admin-password=adminpassword --language=en_US --currency=CUR --timezone=Continent/City --use-rewrites=1 --elasticsearch-port=XXXX

This command will install Magento with Elasticsearch enabled. You should then skip to step 9.

 

The full list of the options supported by the installation script can be obtained at https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-install.html.

The installation script should fail with the following error message:

7. Disable the Elasticsearch modules.

To disable the Elasticsearch modules, please run the following command in the Magento installation directory:

php bin/magento module:disable Magento_Elasticsearch Magento_Elasticsearch6 Magento_Elasticsearch7

You should get the following output:

8. Run the installation script after the Elasticsearch modules have been disabled.

Finally, re-run the installation command:

php bin/magento setup:install --base-url=http://yourdomain.com/magento/ --db-host=db_host --db-name=username_database --db-user=db_username --db-password=db_password --admin-firstname=Your_first_name --admin-lastname=Your_last_name --admin-email=youremail@yourdomain.com --admin-user=adminusername --admin-password=adminpassword --language=en_US --currency=CUR --timezone=Continent/City --use-rewrites=1

Please allow some time for the installation script to complete its execution.

You should get the following output:

9. Cron job

In order for Magento to run properly, it requires a cron job. Setting up Cron jobs is covered in the Cron Jobs section of our documentation. To set up a cron job for Magento, please create a file called magento-cron.sh on your account. You can create the file by using the File Manager in the Control Panel, SSH, or FTP. The file should have the following content:

#!/bin/bash
cd /path/to/your/magento/installation/dir
php bin/magento cron:run 

Then, set up the magento-cron.sh file to run as a Cron job through the Cron Jobs section of the account's Control Panel.

That's it!

Magento is now installed. You should be able to access its default home page at the URL you specified as the --base-url option in the installation command. It should look like this:

Magento storefront which verifies a successful installation

You should be able to access the administrative interface of Magento by adding the Magento Admin URI produced by the installation script to your base URL (e.g. http://yourdomain.com/magento/admin_uniquecode).