If you’re looking to install Magento 2 Open Source, you’re in the right place. Among all open-source eCommerce platforms, Magento 2 stands out as one of the most powerful and flexible solutions, ideal for businesses that require complete control over their store’s features, scalability, and performance.
But let’s be honest: installing Magento isn’t exactly beginner-friendly. Between strict system requirements, Composer commands, and file permissions, the setup process can feel overwhelming, especially if it’s your first time.
No worries — LitExtension will walk you through every step.
In this guide, you’ll learn how to install Magento 2 Open Source using Composer, which is the official and most future-proof method. We’ll also cover alternative installation options, troubleshooting tips, and everything you need to know to get your store up and running on Magento 2.4.8, the latest release as of March 2025.
Before You Install Magento 2
Before diving into the actual installation process, it’s crucial to prepare your environment. Magento 2 is a powerful platform, but it also has strict requirements. Setting things up properly now will save you hours of debugging later.
1. Verify your server meets Magento system requirements
In 2025, Magento 2.4.8 is a significant update that supports newer software stacks. Magento 2 cannot run smoothly on its managed cloud hosting if your server fails to meet the key system requirements. Here's what your server environment should meet or exceed:
Category | Requirement |
Operating system | – Linux distributions only: Ubuntu, Debian, CentOS, RHEL – Not supported: Windows or macOS in production |
Web server | – Apache 2.4 (with mod_rewrite, mod_version) – NGINX 1.x (recommended for performance) |
PHP version | – PHP 8.3 supported – Recommended memory: 2GB+ – Create a swap file if RAM is < 2GB |
Required PHP extensions | bcmath, ctype, curl, dom, gd, intl, mbstring, openssl, pdo_mysql, simplexml, soap, sodium, xsl, zip, json |
Database | – MySQL 8.4 or MariaDB 11.4 – Older versions like MySQL 5.7 are deprecated |
Search engine | – Elasticsearch 7.6+ (required for catalog/product search) – MySQL search removed since Magento 2.4 |
Caching & queue | – Redis (recommended for page/session cache) – RabbitMQ 3.8+ (optional, for async messaging) |
HTTPS & security | – TLS 1.2+ required – Self-signed SSL certificates are not supported for repo.magento.com or PayPal integrations |
Browser support | Latest versions of Chrome, Firefox, Edge, Safari (iOS/macOS), and Chrome on Android |
2. Install Composer on your server
Magento 2 is built around Composer, a PHP dependency manager, for installing and managing code packages. If you haven’t installed Composer yet, use the steps below:
php -r “copy(‘https://getcomposer.org/installer', ‘composer-setup.php');”
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
Then confirm the installation:
composer –version
FYI: Magento 2 no longer uses the Web Setup Wizard — Composer is required for all installations starting from version 2.4 and up.
3. Generate authentication keys from Magento Marketplace
To download Magento packages via Composer, you need to authenticate with repo.magento.com using access keys linked to your Magento Marketplace account.
To get started, create a Commerce Marketplace profile and use it to generate two authentication keys (each with 32 characters). Ensure these keys are linked to a MAGEID (the primary contact's login credentials for your account) that has permission for the Adobe Commerce packages!
Let us break down the steps for you:
- First, go to the Commerce Marketplace and log in. Don't have an account yet? Click Register.
- Click on your account name (top corner on the right) > Choose My Profile.
- On the Marketplace tab, choose Access Keys. Click on Create New Access Key and enter the keys' names. Then, click OK.
- You will now see new private and public keys connected to your account. Click on these keys to copy them to the clipboard. That's it! We're now one step closer to our Magento 2 setup.
These keys act like your credentials for Composer. When prompted during the Magento installation process, you’ll use the public key as your username and the private key as your password.
Note: Save your keys in a secure password manager so you can reuse them when updating or adding new extensions in the future.
4. Understand Magento’s technology stack (optional)
In addition to setting up the system, it is helpful to understand the technologies that Magento 2.4.8 relies on. This makes development, customization, and scaling much smoother, especially for agencies or teams working with multiple merchants.
Here’s a closer look at the stack that powers Magento 2.4.8 (the latest version of Magento as of March 2025):
Stack layer | Technology |
Backend language | PHP 8.3 (latest supported version in Magento 2.4.8) |
Dependency management | Composer 2.8 – required for installing Magento and managing dependencies |
Coding standards | Complies with PSR-1, PSR-2, PSR-3, and supports PSR-4 (recommended for autoloading) |
Frontend technologies | HTML5, CSS3, LESS, RequireJS, KnockoutJS, JQuery |
Caching solutions | – Redis (object/session caching) – Varnish (full-page caching) – File-based caching (default fallback) |
Version control | Git (optional but recommended for dev workflows, deployment, and version tracking) |
With this stack in place and your environment ready, you’re now set to begin the installation process.
How to Install Magento 2 Open Source via Composer
Now that your server is ready and you have your Magento Marketplace authentication keys, it’s time to install Magento 2. We’ll be using Composer, the official and most flexible method for installing and managing Magento projects.
Let's follow the steps below carefully, and we’ll guide you through each command and what it does.
Step 1. Log in as the File System Owner
Before running any Magento CLI commands, you should make sure you're acting as the correct file system owner — the user who has permission to write to the Magento directory. This prevents file permission issues during installation and later operations.
Depending on your setup, there are two common ways to do this:
Option 1: If your Magento files are owned by www-data (common on Ubuntu), use: sudo -u www-data bin/magento <command>
Then replace www-data with the actual owner of your Magento files (e.g. apache on CentOS/RHEL, or magento if you’ve created a dedicated user).
Option 2: If you're using a shell that supports it, you can switch into the owner’s shell and run commands directly: su www-data -s /bin/bash
Now you're logged in as the file owner, and you can run Magento commands without sudo.
If you want to add Magento to your system PATH and run bin/magento from any directory, you can temporarily add it to your terminal session: export PATH=$PATH:/var/www/html/magento2/bin
Replace/var/www/html/magento2/ with the path to your Magento installation.
Step 2. Download Magento using Composer
Navigate to the directory where you want to install Magento (this can be inside your web server’s root directory, e.g. /var/www/html/): cd /var/www/html/
Now, run the following command to download the latest version of Magento 2 Open Source: composer create-project –repository=https://repo.magento.com/ magento/project-community-edition magento2
This will create a new folder called magento2 (you can rename this), download all Magento core files and PHP dependencies, and prompt you for authentication keys (from your Magento Marketplace account). Then, you will be prompted for your Magento Marketplace authentication keys (public key as username, private key as password).
Step 3. Install Magento via Command Line
This is where Magento gets installed — creating your admin user, initializing the database schema, and generating encryption keys.
Run the following command (customize values to match your preferences):
bin/magento setup:install \
–admin-firstname=”John” \
–admin-lastname=”Doe” \
–admin-email=”[email protected]” \
–admin-user=”adminuser” \
–admin-password=”StrongP@ssw0rd123″ \
–language=”en_US” \
–currency=”USD” \
–timezone=”America/New_York” \
–use-rewrites=1
The password requirements must include uppercase, lowercase, numbers, special characters, and be at least 8 characters long.
If you're using OpenSearch instead of Elasticsearch, you can add:
–search-engine=opensearch \
–opensearch-host=your-opensearch-host \
–opensearch-port=9200 \
–opensearch-index-prefix=magento2 \
–opensearch-timeout=15
This is useful in enterprise setups or when Elasticsearch is not available.
If everything is configured correctly, Magento will complete the setup and display both your frontend store URL and your admin login URL.
Step 4. Set file & folder permissions
Once Magento is installed, you need to set the correct file and folder permissions. This ensures your store runs smoothly and securely, especially when serving assets or running CLI commands.
From your Magento root directory, run the following:
sudo chown -R www-data:www-data /var/www/html/magento2/
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod 644 {} \;
sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod 755 {} \;
Then, replace www-data with the actual user that your web server uses (e.g., apache or nginx). This command assigns files 644 permissions and directories 755, which is a secure and functional setting for Magento.
Step 5. Post-installation configuration
Now that Magento is installed and permissions are set, it's time to finalize your setup. These post-installation tasks will help ensure your store runs efficiently, securely, and is ready for real traffic.
To begin, visit the Magento admin panel using the custom admin path you configured during installation: http://yourdomain.com/adminsecure. Log in using the admin username and password you created in Step 4.
Then, it's time to switch to production mode. Magento installs in developer mode by default, which is helpful for debugging but slows down performance. Before going live, switch to production mode for improved speed and stability.
From your Magento root directory, run: php bin/magento deploy:mode:set production, and this will compile code and static files, disable automatic file generation, and improve caching behavior. This may take a few minutes, depending on your server. If you see permission errors, double-check that file/folder ownership and permissions are correct.
Step 6. Verify the Magento 2 installation
Before you begin building your store or customizing themes, take a few minutes to verify that everything works correctly.
Open your browser and go to: http://yourdomain.com/
You should see Magento’s default Luma theme on the homepage. If it loads properly:
- Your server, PHP, database, and base URL are all configured correctly
- Magento's public-facing frontend is ready
If the page returns an error or displays a blank screen, check your web server logs to verify permissions and rewrite rules.
After that, log in to your Magento admin: http://yourdomain.com/adminsecure, enter your admin credentials, and you land on the Magento dashboard. Click around:
- Go to Stores > Configuration
- Open Reports > Statistics
- Navigate to System > Cache Management
If everything responds correctly, your backend is working perfectly.
Extra Troubleshooting Tips to Install Magento 2 via Composer
Our Magento 2 installation guide above is very clear. However, things do not always go as smoothly as planned, and common issues might surface! In that case, you can consider some possible solutions here:
1. “The requested PHP extension ext-mbstring * is missing from your system.”
What does this error mean? It indicates your PHP extension (‘mbstring' package) has not been installed. Just use the command below to install it now:
sudo apt-get install php-mbstring
2. The requested PHP extension ext-iconv * is missing from your system.”
Just like issue #1, the message implies you have not yet installed the PHP extension (‘iconv‘ package). The following command can fix it for you:
sudo apt-get install php-iconv
3. “Fatal error: Allowed memory size exhausted”
This time, you have likely set your PHP memory limit a bit too low. Add this code to increase the limit in the php.ini.file:
memory_limit = 2G
4. “Class ‘Locale' not found”
The message popped up for a reason. Did you forget to install the PHP extension (‘intl' package)? No worries; there's still time to fix that mistake:
sudo apt-get install php-intl
5. Permission errors
Another frequent problem when installing Magento 2 is the permission errors. To fix these issues, you must set the correct directory and file permissions. Remember that files must have 644 permissions, and folders have 755 permissions. Also, make sure your website server user already owns all Magento directories and files.
6. Missing dependencies
Lastly, there's the issue of missing dependencies. Go to the root Magento 2 directory, then run composer update or composer install command!
4 Other Alternatives to Install Magento 2
So far, we have discussed the steps to install Magento 2 using Composer and addressed some common issues you may encounter. However, if you'd rather not use Composer or prefer different methods, here are five alternatives to go for:
(Note that these alternative methods might take less time but lack the above benefits that Composer offers)
1. Via the Cloudways platform
If using codes and commands (like those in our guides above) isn't your strong suit, the Cloudways platform is a fantastic alternative! Just follow these six simple steps:
- Log in to your Cloudways account or create one.
- Create a new server, then choose the Magento version from the Application dropdown. Provide application and server details.
- Choose your preferred Cloud Provider. Select the server size and bandwidth that best suit your needs.
- Choose your desired server storage. And don't worry, this option is not set in stone; you can always scale it up later if needed.
- Pick a server location. Click Launch Server. That's it!
- Once the server preparation is complete, proceed to the Application Management section. Use Access Details to sign in to your store.
2. Via Zip Archive
Next on our list is Zip Archive, which does involve some code and commands but is slightly easier than Composer. You need to keep three main steps in mind:
- Download the source code from this link.
- Upload the downloaded archive to your current server and extract it into your root Magento directory. Just use the extract/unzip function for your shared hosting. However, if you're operating on your own server, run these commands instead:
# File .tar.gz
tar zxf <yourfilename># File .zip
unzip <yourfilename> - Then, add a write permission to the pub, app/etc, var folders:
chmod 777 -R var
chmod 777 -R app/etc
chmod 777 -R pub - Launch the installation wizard, then follow the prompts to complete the installation of Magento 2.
3. Via Github
Another popular option is to install via GitHub. Some think this method only works with sample data, but we've found that it works just fine on its own! Here's how:
Install Magento 2 via Github without sample data
- First, you need to get the Magento 2 files. You can either clone the Magento 2 repository (click here) or download the necessary release from here.
- Make a new, empty directory to store the Magento 2 files.
- Navigate to the new directory and run the command below:
git clone [email protected]:magento/magento2.git - Wait for the deployment to complete, then install the required dependencies by running:
composer install - Now, it's time to install Magento 2! Use the following command, making sure to replace the placeholders (base-url, db-password, db-name, admin-password, and admin-email) with your specific details:
php -f bin/magento setup:install –base-url=http://m2.loc/2.07/github/ –backend-frontname=admin
–db-host=localhost –db-name=m2git –db-user=root –db-password=inchoo –admin-firstname=Magento
–admin-lastname=User –[email protected] –admin-user=admin –admin-password=magento456
–language=en_US –currency=USD –timezone=America/California –use-rewrites=1 - Open your web browser and go to the local URL you set during installation. If the page loads correctly, congratulations!
Install Magento 2 via Github with sample data
We just told you how to install Magento 2 via GitHub without sample data. If you want to install the sample data in the setup as well, here's how:
- First, go to your web root directory. Make sure it's not the Magento 2 directory!
- Run the following command to clone the Magento 2 sample data repository:
git clone [email protected]:magento/magento2-sample-data.git - Go to this cloned Magento 2 directory, then run the command below to link the sample data to the Magento 2 installation:
php -f dev/tools/build-sample-data.php — –ce-source=”your Magento CE install dir” - For Linux users, set the correct permissions and ownership:
chown -R :your web server group name
find . -type d -exec chmod g+ws {} \; - Navigate to the var/ folder in your Magento 2 directory and clear the cache with the following command:
rm -rf cache/* page_cache/* generation/* - Finally, install the sample data using these commands:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Now, the sample data should be successfully installed on your Magento 2 setup!
4. With XAMPP on localhost
If none of the above options works for you, why not try XAMPP to install Magento 2? Let us guide you through the process:
- Install XAMPP, then download the package from this Magento website.
- Create a new folder named “Magento” in the xampp/htdocs directory.
- Extract the downloaded archive to the Magento folder, then open the XAMPP Control Panel, navigate to Apache, and click on Config.
- From the menu that appears, select PHP (php.ini).
- Locate these lines: extension=php_xsl.dll and extension=php_intl.dll, and Remove “;” at the beginning.
- Go back to the XAMPP Control Panel, then start both MySQL and Apache.
- Open your browser and go to localhost/magento2. Agree to the terms and proceed with the Magento setup.
FAQs
Can I install Magento 2 without Composer?
Technically yes, but it’s not recommended. Magento deprecated the Web Setup Wizard in version 2.3.6, and Composer has been the official method ever since. It offers better dependency management, cleaner version control, and long-term flexibility.
What PHP version is best for Magento 2.4.6?
Magento 2.4.6 officially supports PHP 8.1 (recommended) and PHP 8.2 (starting from 2.4.6-p1). You should avoid PHP 7.4 or older — support has ended and they’re no longer secure or compatible with the latest Magento versions.
Note: Magento 2.4.8 supports PHP 8.3 as of March 2025.
Do I need a license for Magento Open Source?
No, Magento Open Source is 100% free to download and use under the OSL 3.0 license. You don’t need to pay for a license — but you’ll need to handle your own hosting, support, and development.
Why is it so difficult to install Magento 2?
Magento 2 is powerful — but it’s also complex. It requires a properly configured Linux server, Composer, PHP extensions, and a search engine like Elasticsearch and correct file permissions and CLI installation.
Can I switch from Open Source to Adobe Commerce later?
Yes — Magento is designed to be upgrade-friendly.
You can migrate from Open Source to Adobe Commerce at any time by purchasing an Adobe Commerce license, installing the Adobe Commerce edition or migrating your database, modules, and theme (if compatible).
Final Words
We've guided you through 6 easy steps to install Magento 2. Although some coding is involved, the process remains quite straightforward.
However, if you're new to this and need to migrate from another platform to Magento as soon as possible, our experienced LitExtension Expert team is ready to help.
We have assisted over 200,000 customers worldwide, from more than 100 countries, in migrating their stores to various platforms, with a satisfaction rate of 99% or higher. You need zero technical knowledge during the entire process, and our 24/7 support team will be with you every step of the way.
Visit our LitExtension blog and join our eCommerce community for more support.