How to Install Magento 2.4 via Command Line
Magento 2.4 is released!
The one thing consistent in this new normal is the Magento community’s tradition to upgrade and improve with each new version!
The latest Magento 2.4 was released on July 28, ’20. And our developers were quick enough to download the latest Magento 2 version to investigate what’s in store for them.
If you are also one of us, I bet you too would want to check it out, and hence, here’s the method to install Magento 2.4 via command line that you can implement to dive into Magento 2.4.
Install Magento 2 and start with the most prominent features of the latest version like:
- 2FA security for Magento 2 admin panel
- Purchase approval workflows
- Seller assisted shopping
- In-store pickup
- New media gallery
- PWA Development
- Headless commerce
We were pretty much excited, and I’m sure you are too!
Magento has one command-line interface that performs both installation and configuration tasks: <magento_root>/bin/magento
.
However, the new interface also allows to:
- Install Magento
- Clear cache
- Manage indexes and reindexing
- Create translation dictionaries and translation packages
- Generate non-existent classes such as factories and interceptors for plug-ins
- Generate the dependency injection configuration for the object manager
- Deploy static view files
- Create CSS from Less
Benefits of using Magento 2 Command Line:
- A single command (
<magento_root>/bin/magento list
) lists all available installation and configuration commands. - Symfony based consistent UI
- The CLI is extensible so third party developers can “plug in” to it
- Not display the commands for disabled modules
Before you start the Magento 2 installation process, make sure you meet all the system requirements for Magento 2.4
Method to Install Magento 2.4 via Command Line:
Run the below command in the command line:
1 |
php bin/magento setup:install --base-url="http://localhost/mag24/" --db-host="localhost" --db-name="mag24" --db-user="root" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --admin-user="admin" --admin-password="admin123" --language="en_US" --currency="INR" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" |
Note: If you witness an syntax error in unexpected way, while installing Magento 2.4 via command line check the solution for it.
There are some other common issues faced while installing Magento 2.
Here’s a quick fix for all of those issues:
Common Magento 2 Installation Issues and their solution:
Check each error and its solution below:
-
-
Reflection Exception Error
[ERROR] exception ‘ReflectionException’ with message ‘Class Magento\Framework\StoreManagerInterface does not exist’ in /<path>/lib/internal/Magento/Framework/Code/Reader/ClassReader.phpSolution:
- Clear the directories and files under Magento’s var subcategory
- Install Magento again
- Run these commands with root privileges for your Magento file system$ cd <the name of your Magento install directory>/var$ rm -rf var/cache/* di/* generation/* page_cache/*
- In case you are using Redis, clear redis cache –$ redis-cli FLUSHALL
-
Fatal PDO Error
PHP Fatal error: Class ‘PDO’ not found in /var/www/html/magento2/setup/module/Magento/Setup/src/Module/Setup/ConnectionFactory.php
on line 44
Solution:
Check if you have installed all of the below extensions:
-
- ext-bcmath
- ext-ctype
- ext-curl
- ext-dom
- ext-gd
- ext-hash
- ext-iconv
- ext-intl
- ext-mbstring
- ext-openssl
- ext-pdo_mysql
- ext-simplexml
- ext-soap
- ext-xsl
- ext-zip
- lib-libxml
-
-
Composer version error
ErrorException]file_get_contents(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directoryThis is a known error with versions of Composer and produces the above error.
If you are using the version of composer released between November 21 to November 26, 2015, you’ll get this error.
Check the composer’s version using the command – composer -v
Either upgrade or downgrade the version of the composer to the version that is not released between these dates.
Use these commands for the same:
Upgrade composer – composer self-update
Downgrade composer – composer self-update 1.0.0-alpha11
After that, delete Magento 2 directory and subdirectories and download Magento again.
-
Errors installing optional sample data
The below errors are often faced while you install sample data in Magento 2. Check the errors and their solutions:
- Permission errorModule ‘Magento_CatalogRuleSampleData’:[ERROR] exception ‘Magento\Framework\Exception\LocalizedException’ with message ‘Can’t create directory /var/www/html/magento2/generated/code/Magento/CatalogRule/Model/.’ in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Generator.php:103(more)`Next exception ‘ReflectionException’ with message ‘Class Magento\CatalogRule\Model\RuleFactory does not exist’ in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php:29(more)This error is caused by the file system permissions settings. Fix it by setting up your access permissions as a user with root privileges.
- Production mode errorPHP Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Console\Input\ArrayInput::__construct() must be of the type array, object given, called in /<path>/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 97 and defined in /<path>/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php:37You’ll face this error when you try to install optional sample data in production mode with the composer instead of installing it in the developer mode.To fix this, log in as Magento file system owner and run these commands:cd <magento_root>bin/magento deploy:mode:set developerrm -rf generated/code/* generated/metadata/*bin/magento sampledata:deploy
- SELinux errorPHP Fatal error: Call to undefined method Magento\Catalog\Model\Resource\Product\Interceptor::getWriteConnection() in /var/www/magento2/app/code/Magento/SampleData/Module/Catalog/Setup/Product/Gallery.phpon line 144Disable SELinux to fix this error.
- Develop branch errorMagento\Setup\SampleDataException] Error during sample data installation: Class Magento\Sales\Model\Service\OrderFactory does not existSwitch to the master branch:cd <magento_root>git checkout mastergit pull origin master
That’s it with Magento 2.4 installation via command line. Likewise you can also learn to Install Magento 2 on Ubuntu with our step wise guide.
If you have any doubts in the installation process or cannot fix any of the above errors, please mention them in the Comments section below.
I’d be happy to help you out.
Also, share the post with fellow Magento developers via social media.
Thank you.
Still need help? Hire our Adobe-certified Magento experts.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
12 Comments
I install magento 2.4.4 successfully. when i open admin page as well as frontend page .all pages are 404.Please help me.
Hello Vivek,
The below link might be helpful for you in this case:
https://meetanshi.com/blog/install-magento-2-4-2-on-localhost-using-xampp/
Thank You
Starting Magento installation:
File permissions check…
[Progress: 1 / 15]
Required extensions check…
exit from magento install….
Hello,
It seems like required PHP extension is missing. Please check the error log to know the exact cause.
Thank You
I am updating Magento from 2.3.3 to 2.4.2 and getting the following error:
PHP Fatal error: Uncaught Error: Cannot instantiate interface Magento\Theme\Model\Theme\StoreThemesResolverInterface in /chroot/home/af910971/96c7639f97.nxcli.net/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
I have flushed cache, enabled all modules and the di.xml file
ideas?
Hello Steve,
Maybe you have made a mistake in upgrade process. You may take experts help for Magento version upgrade at https://meetanshi.com/annual-magento-upgrade-service.html
Thank You
Not Found
The requested URL was not found on this server.
Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.3.27 Server at localhost Port 8080
iam getting this error and new to learning mogento. Please help
thanks in advance
Hello,
First, follow the solution at https://meetanshi.com/blog/install-magento-2-4-via-command-line/
Install the extension apart from Magento 2.4.2 so that if the mistake is in previous steps, you can identify it.
Also, use Php 7.4 version instead of Php 7.3
Thanks.
Good day
I am not a developer but been trying to install the magento store on my xampp server/platform
The first I did install it well but was not opening admin. I uninstall it to restart the process. This second time got an error I did not get before. the error is
in compat.php line 1927: this is not implemented, as it is not possible to implement argon2i with acceptable performance in pure-php
would you please help with a solution. I do have an php libsodium working already and is current but still getting the same issue at installation progress 1385/1390, Thank you in advance
Hello Fred,
Which Magento 2 version are you trying to install?
Thanks
I was installing magento-ce-2.4.2-2021-01-24-04-25-13 with sample data
Hello,
Use the below link to install Magento 2.4.2
https://meetanshi.com/blog/install-magento-2-4-2-on-localhost-using-xampp/
Thank You.