Answers

We’ve gathered common questions about Magento and are happy to share our answers.

Answers
Staylime’s related service

How to install and set up Magento?

To install Magento 2.4.x on your server, follow these steps:

Step 1: Pre-install checks

First, run a pre-installation check to ensure you have everything required to install Magento:

  1. A web server that meets Magento’s requirements, with SMTP capabilities.
  2. A separate filesystem owner for Magento.
  3. Composer version 1.x for Magento 2.4.1 and earlier or Composer 2.x for Magento 2.4.2 and later.
  4. Authentication keys from your Magento Marketplace account. If you don’t have an account you can create it here
  5. Configured Elasticsearch before installing Magento.

Step 2: Download Magento 2 Open Source metapackage

Next, you must obtain the Magento Open Source metapackage from the Magento code repository using Composer. You can do this by executing the following command in your terminal:

$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>

You can enter the absolute path of your directory by replacing <install-directory-name> with the actual location like /var/www/magento or replace it with a ‘.’ if you’re already in the destination directory.

At this point, you will be asked to enter your Magento authentication keys. Enter the public key as the username and the private key as the password. Composer will take approximately 5–10 minutes to complete the metapackage download.

Step 3: Set pre-installation file permissions

You need to set correct files permissions for the webserver group to allow it to write the files necessary in the Magento filesystem. The basic approach to ownership and permissions in Magento is described here, the specific procedure for your server type you can select here. By doing this, we’ve prepared the filesystem for installation and are now ready to run the installation script.

Step 4: Install Magento

To install Magento, copy the following commands and replace all values as necessary before pasting and running it in your terminal:

$ php bin/magento setup:install --base-url=http://example.com/ --db-host=localhost --db-name=magento --db-user=magentodbuser --db-password=dbuserpassword --admin-firstname=Admin --admin-lastname=Admin [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

Here you can find a detailed description of all available Magento installation options.

Once the installation script has finished executing, you will receive the confirmation of successful completion and a randomly generated URL to access the admin panel in your terminal. You can use this URL or set your own by running the following command and replacing <custom-admin-url-here> with your custom URL:

$ php bin/magento setup:config:set --backend-frontname="<custom-admin-url-here>"

After the installation is completed, your store will also send out an automated email to the store admin with instructions on how to access the admin account and configure two-factor authentication.

Step 5: Set up a cron job

Although you’ve successfully installed Magento on your server, you must set up cron tasks through the command line before you’re able to start using your store.

Cron helps Magento run background tasks on a pre-configured schedule. While you can manually configure the schedule and frequency of execution, using the default settings will also suffice.

To setup cron, run the following command in the terminal:

$ php bin/magento cron:install

To verify cron is set up, run the following command:

$ crontab -l

Step 6: Verify the installation

Finally, verify that the frontend of your store is working by navigating to your website’s URL in a web browser. Once you’ve confirmed that it works, it’s time to log in to the admin panel.

As of Magento 2.4, you must set up two-factor authentication before accessing Magento as an added security measure.

Click on the link received via email and follow the instructions to configure two-factor authentication with your device. After this, you can log in to the admin panel using the credentials you entered while running the install script.

Congratulations, you’ve successfully installed Magento on your server, set up cron tasks, and verified the frontend and backend of your Magento store works.