We will be using MGT Commerce’s Docker container to install the latest version of Magento 2.4.2.
If you haven’t setup the MGT Commerce’s Docker image then you can simply run the following command to set one up on your local:
docker run -d --net=bridge -v /var/lib/mysql -v /home/cloudpanel --restart=always --privileged -h mgt-dev --name mgt-dev -it -p 80:80 -p 443:443 -p 8443:8443 -p 22:22 -p 3306:3306 -p 9200:9200 -p 15672:15672 mgtcommerce/mgt-dev:v2
Once the image is installed, you will need to go to https://127.0.0.1:8443/ as that’s where the docker image is installed.
Next, click on the Add Domain button to add a new local domain to install your Magento:
Important: Magento has removed the root index.php in Magento 2.4.2 and moved it to the ./pub directory so you will need to add ./pub to your document root as shown in the image above.
Once the domain is setup, you will need to create a database which you can create by clicking on the Databases link from the left hand menu.
Next, it is now time to download Magento on your local server but first you will need to login to the MGT Commerce’s Docker Image.
Open terminal and ssh using the following details:
FTP HOST: 127.0.0.1:22
USERNAME: root
PASSWORD: root
.. then navigate to the htdocs directory i.e.cd htdocs/playground.magento.com/
Finally, run the following to download Magento to the site root:
php7.4 /usr/local/bin/composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition playground.magento.com
This should download Magento and finally install it using the following command:
Once the installation is complete, you should be able to access Magento on https://playground.magento.com/ (but remember you will need to add this entry in your hosts file to access the site).