Magento 2 Xampp Installation

Running Magento 2 in Windows with XAMPP


Photo by Nicole De Khors · Burst, Some Rights Reserved

Magento is an open source ecommerce platform, written in PHP and relying on MySQL/​MariaDB for persistence. According to BuiltWith, Magento is the third most used platform in ecommerce websites. It began its life in 2008 with its first general release, and a major update (Magento 2) was released in 2015.

And now, more than three years after, Magento 1 is slowly dying: There won’t be any more quality fixes or security updates from June 2020, and there won’t be extended support for fixes or new payment methods. So the obvious choice will be Magento 2 from now on.

After these 10 steps, I guarantee you will create a Magento 2 site on localhost with XAMPP. In case you need, we also publish a guide of Magento Installation for Magento version 1.x.Important Note: Before installing any version of Magento 2, you could easily find your favorite Magento 2 version in this article: UP-TO-DATE Magento Download (all Magento 2 versions). Select the latest Magento 2.x Community Edition in zip format and click on download. After download, create a folder in htdocs folder in xampp installation directory. For example, “C: xampp htdocs magento2”. Now go to download location of the zip file, press and hold shift key and right click the downloaded Magento2 zip file.

Create a “magento” (or whatever name you prefer) database in MySQL from phpMyAdmin, installed already on XAMPP: localhost/phpmyadmin. Run the Magento 2 setup from localhost/magento (replace the “magento” part of the URL with whatever name you have chosen to host Magento). In this step, we will install 2 components that are required to run Magento 2 on localhost environment XAMPP and COMPOSER (for windows) XAMPP First of all, we will download and install Xampp, a web server solution stack package that helps developers to create and test their applications on a local webserver.

But is it fully tested yet? Is it stable enough? If we already have a website running with Magento 1, what should we do? Migrating to Magento 2 is not just hitting an “Update” button: Themes are incompatible, most extensions won’t work, and of course, there’s a big set of changes to get familiar with.

So a good approach might be to get a clean Magento 2 version deployed locally, to look what we need to do to get our website updated and running, test the backend, find where the configuration sections are located, and so on. And many business users, and even some developers like myself, have Microsoft Windows installed on our computers.

Environment setup

The environment I used for this testing installation was Windows 10 Professional. As a first step, we’ll need to make sure that localhost is published in our local hosts file:

  • Navigate to the folder %SystemRoot%system32driversetc
  • Backup the existing hosts file
  • Open a text editor with administrator rights
  • Open the hosts file
  • Make sure the first line after the commented (#) lines is 127.0.0.1 localhost and the second is ::1 localhost
  • Open a cmd window with administrator rights and run the command ipconfig /flushdns
Magento 2.4 installation

Now we’re ready to install the environment needed to run Magento. I recommend using XAMPP, a free Apache distribution for Windows that includes MariaDB, PHP, and Perl in a single package. Magento 2 currently runs with PHP 7.2 and it will not work with newer versions.

  • Install XAMPP 7.2 with default settings: apachefriends.org/xampp-files/7.2.15/xampp-win32-7.2.15-0-VC15-installer.exe
  • Download Magento 2. You will need to register on the website first: magento.com/tech-resources/download
  • Create a new “magento” subfolder (or whatever name you prefer) inside the htdocs folder in the XAMPP installation (usually C:xampp) and uncompress the Magento 2 archive there.
  • Start the XAMPP Control Panel from the Windows start menu. In the “Apache” section, click the “Config” button and, on the menu that appears, select “PHP (php.ini)”. Remove the semicolon before the extension=intl, extension=soap, and extension=xsl texts to enable the intl, soap and xsl extensions.


Screenshot of the XAMPP Control Panel with the PHP config menu displayed.

MySQL and Magento setup

We have all the files in place and the environment ready to start configuring the database and install Magento 2.

  • Start the Apache and MySQL services from the XAMPP Control Panel. Wait for the green status texts to appear.

  • Create a “magento” (or whatever name you prefer) database in MySQL from phpMyAdmin, installed already on XAMPP: localhost/phpmyadmin

  • Run the Magento 2 setup from localhost/magento (replace the “magento” part of the URL with whatever name you have chosen to host Magento). If the setup program requires to do any additional configuration change, do it as instructed. Do a screenshot or save the final page contents for later use.


Example of the page that will be displayed when the Magento 2 installation finishes.

Fixing known issues

When we finish the installation process, we will have a Magento 2 instance running on our host. But we’re not ready yet! There are a couple known bugs with Magento 2 and XAMPP at the moment I’m writing this post:

  • The Magento admin page may not work (it shows a blank page): Fix this issue by updating the “isPathInDirectories” function inside the Validator.php file as instructed in this article.

  • We might not be able to upload images (like a custom logo or product pictures): Fix this issue by updating the design_config_form.xml file as shown here.

After we finish making these changes, we will need to restart the Apache service from the XAMPP control panel. And that’s it! We should be ready to open the Magento front page, and login into the backend.


An empty home page with the default theme enabled in Magento 2.


This is how the Magento 2 back-end dashboard looks like once we login.

Setting up the store: A roadmap

The purpose of this article is to get Magento 2 up and running on Windows computer, and that’s what I hope we’ve achieved so far. But just to point in a direction on what to do next, below is my usual roadmap to set up the store, add a few products and publish the catalog on the home page.

  • Change the default store name and logo from the section Content > Design > Configuration and choose “Edit” in the “Default store view”.
  • Set up the default store configuration from the section Stores > Configuration.
  • Create the product categories from the section Catalog > Categories. Set up a category name and its dependency from another category, or from the default master category.
  • Create/edit the product attributes from the section Stores > Attributes (check the option “visible in storefront” to show the products in the product page). For example, custom attributes for book products would be Author, Publisher..
  • Add the attributes to the default attribute set from the section Stores > Attribute. This is required for the attributes to show up when adding a new product by default.
  • Create a set of products from the section Catalog > Products. Set the custom variations for each product from the “Customizable options” section. Set up a short and long description, a custom SKU for each customizable option, and a tax mode.
  • Add a widget to the homepage to show the product catalog from the section Content > Homepage > Edit > Show/Hide Editor > Add widget > Products list. Here we can also add any content we like, including HTML tags, images, and third-party content.

Conclusion

It’s possible—​and pretty straightforward—​to run a Magento 2 instance in Windows with XAMPP. But this is just a kick-off, a simple overview: there’s a lot more to do if we want to get a full ecommerce website that is ready to scale up and support enterprise-​level traffic, like caching optimization, load balancing, and advanced server-​side monitoring.

Magento 2 xampp installation manual pdf

Sourcetree git cheat sheet. At End Point, we have professionals with a strong background in deploying powerful, reliable, fully responsive, fast, and SEO-​optimized ecommerce websites. We have experience in migrating Magento to newer versions, and even creating full Magento 2 websites from scratch. Drop us a line if you want to hear more.

Comments

Visit theGitHub issueto view and write comments.

Totally lost? Need a helping hand? Try our Quick start install or Contributor install guides.

If you chose to enable SELinux, see SELinux and iptables.

Magento command-line interface (CLI)

Magento has one command-line interface that performs both installation and configuration tasks: <magento_root>/bin/magento. The new interface performs multiple tasks, including:

  • Installing Magento (and related tasks such as creating or updating the database schema, creating the deployment configuration, and so on).
  • Clearing the cache.
  • Managing indexes, including reindexing.
  • Creating translation dictionaries and translation packages.
  • Generating non-existent classes such as factories and interceptors for plug-ins, generating the dependency injection configuration for the object manager.
  • Deploying static view files.
  • Creating CSS from Less.

Other benefits:

  • A single command (<magento_root>/bin/magento list) lists all available installation and configuration commands.
  • Consistent user interface based on Symfony.
  • The CLI is extensible so third party developers can “plug in” to it. This has the additional benefit of eliminating users’ learning curve.
  • Commands for disabled modules do not display.

This topic discusses installing the Magento software using the CLI. For information about configuring Magento, see the Configuration Guide.

Before you start your installation

Before you begin, complete the following steps:

  • Verify that your system meets the requirements discussed in Magento system requirements.

  • Complete all prerequisite tasks.

  • Complete the first installation steps. See Your install or upgrade path.

  • After you log in to the Magento server, switch to the Magento file system owner.

  • Review the Get started with the command-line installation overview.

You must install Magento from its bin subdirectory.

You can run the installer multiple times with different options to complete installation tasks like the following:

  • Install in phases—For example, after you configure your web server for Secure Sockets Layer (SSL), you can run the installer again to set SSL options.

  • Correct mistakes in previous installations.

  • Install Magento in a different database instance.

By default, the installer does not overwrite the Magento database if you install the Magento software in the same database instance. You can use the optional cleanup-database parameter to change this behavior.

See also Update, reinstall, uninstall.

Completely secure installation

To use Secure Sockets Layer (SSL), also referred to as HTTPS, for both the Magento Admin and the storefront, you must set all of the following parameters:

  • --use-secure: Set to 1
  • --base-url-secure: Set to a secure URL (that is, starting with https://)
  • --use-secure-admin Set to 1

More details about these parameters can be found later in this topic.

Magento 2.4 Installation

Installer help commands

You can run the following commands to find values for some required arguments:

Magento 2 Xampp Installation
Installer argumentCommand
Languagemagento info:language:list
Currencymagento info:currency:list
Time zonephp magento info:timezone:list

If an error displays when you run these commands, verify that you updated installation dependencies as discussed in Update installation dependencies.

Install the Magento software from the command line

The install command uses the following format:

The following tables describe the installation option names and values. For example installation commands. see Sample localhost installations.

Any options that contain spaces or special characters must be enclosed in either single or double quotes.

Magento 2 Xampp Installation

Admin credentials:

The following options specify the user information and credentials for the Magento admin user.

In Magento Commerce version 2.2.8 and later, you can create the Magento admin user during or after installation. If you create the user during installation, all admin credential variables are required. See Sample localhost installations.

NameValueRequired?
--admin-firstnameMagento administrator user’s first name.Yes
--admin-lastnameMagento administrator user’s last name.Yes
--admin-emailMagento administrator user’s e-mail address.Yes
--admin-userMagento administrator username.Yes
--admin-passwordMagento administrator user password. The password must be at least 7 characters in length and must include at least one alphabetic and at least one numeric character. We recommend a longer, more complex password. Enclose the entire password string in single quotes. For example, --admin-password='A0b9%t3g'Yes

Site and database configuration options:

Installation
NameValueRequired?
--base-urlBase URL to use to access your Magento Admin and storefront in any of the following formats:
http[s]://<host or ip>/<your Magento install dir>/.
Note: The scheme (http:// or https://) and a trailing slash are both required.
<your Magento install dir> is the docroot-relative path in which to install the Magento software. Depending on how you set up your web server and virtual hosts, the path might be magento2 or it might be blank.
To access Magento on localhost, you can use either http://127.0.0.1/<your Magento install dir>/ or http://127.0.0.1/<your Magento install dir>/.
- `` which represents a base URL defined by a virtual host setting or by a virtualization environment like Docker. For example, if you set up a virtual host for Magento with the hostname magento.example.com, you can install the Magento software with --base-url= and access the Magento Admin with a URL like http://magento.example.com/admin.
Yes
--backend-frontnameUniform Resource Identifier (URI) to access the Magento Admin. You can omit this parameter to let Magento generate a random URI for you with the following pattern admin_jkhgdfq.
We recommend a random URI for security purposes. A random URI is harder for hackers or malicious software to exploit.
The URI displays at the end of the installation. You can display it later at any time using the magento info:adminuri command.
If you choose to enter a value, we recommend you not use a common word like admin, backend, and so on. The Admin URI can contain alphanumeric values and the underscore character (_) only.
No
--db-hostUse any of the following:
- The database server’s fully qualified hostname or IP address.
- localhost (default) or 127.0.0.1 if your database server is on the same host as your web server.localhost means the MySQL client library uses UNIX sockets to connect to the database. 127.0.0.1 causes the client library to use the TCP protocol. For more information about sockets, see the PHP PDO_MYSQL documentation.
Note: You can optionally specify the database server port in its hostname like www.example.com:9000
Yes
--db-nameName of the Magento database instance in which you want to install the Magento database tables.
Default is magento2.
Yes
--db-userUsername of the Magento database instance owner.
Default is root.
Yes
--db-passwordMagento database instance owner’s password.Yes
--db-prefixUse only if you’re installing the Magento database tables in a database instance that has Magento tables in it already.
In that case, use a prefix to identify the Magento tables for this installation. Some customers have more than one Magento instance running on a server with all tables in the same database.
The prefix can be a maximum of five characters in length. It must begin with a letter and can include only letters, numbers, and underscore characters.
This option enables those customers to share the database server with more than one Magento installation.
No
--db-ssl-keyPath to the client key.No
--db-ssl-certPath to the client certificate.No
--db-ssl-caPath to the server certificate.No
--languageLanguage code to use in the Admin and storefront. (If you have not done so already, you can view the list of language codes by entering magento info:language:list from the bin directory.)No
--currencyDefault currency to use in the storefront. (If you have not done so already, you can view the list of currencies by entering magento info:currency:list from the bin directory.)No
--timezoneDefault time zone to use in the Admin and storefront. (If you have not done so already, you can view the list of time zones by entering magento info:timezone:list from the bin directory.)No
--use-rewrites1 means you use web server rewrites for generated links in the storefront and Admin.
0 disables the use of web server rewrites. This is the default.
No
--use-secure1 enables the use of Secure Sockets Layer (SSL) in storefront URLs. Make sure your web server supports SSL before you select this option.
0 disables the use of SSL with Magento. In this case, all other secure URL options are assumed to also be 0. This is the default.
No
--base-url-secureSecure base URL to use to access your Magento Admin and storefront in the following format: http[s]://<host or ip>/<your Magento install dir>/No
--use-secure-admin1 means you use SSL to access the Magento Admin. Make sure your web server supports SSL before you select this option.
0 means you do not use SSL with the Admin. This is the default.
No
--admin-use-security-key1 causes the Magento software to use a randomly generated key value to access pages in the Magento Admin and in forms. These key values help prevent cross-site script forgery attacks. This is the default.
0 disables the use of the key.
No
--session-saveUse any of the following:
- db to store session data in the database. Choose database storage if you have a clustered database; otherwise, there might not be much benefit over file-based storage.
- files to store session data in the file system. File-based session storage is appropriate unless the Magento file system access is slow, you have a clustered database, or you want to store session data in Redis.
- redis to store session data in Redis. If you will be using Redis for default or page caching, Redis must be already installed. See Use Redis for session storage for additional information about configuring support for Redis.
No
--keyIf you have one, specify a key to encrypt sensitive data in the Magento database. If you don’t have one, Magento generates one for you.Yes
--cleanup-databaseTo drop database tables before installing the Magento software, specify this parameter without a value. Otherwise, the Magento database is left intact.No
--db-init-statementsAdvanced MySQL configuration parameter. Uses database initialization statements to run when connecting to the MySQL database. Consult a reference similar to this one before you set any values.
Default is SET NAMES utf8;.
No
--sales-order-increment-prefixSpecify a string value to use as a prefix for sales orders. Typically, this is used to guarantee unique order numbers for payment processors.No

Elasticsearch configuration options:

NameValueRequired?
--search-engineThe version of Elasticsearch to use as the search engine. Possible values are elasticsearch7, elasticsearch6, and elasticsearch5. The default is elasticsearch7. Elasticsearch 5 has been deprecated and is not recommended.No
--elasticsearch-hostThe host name or IP address where Elasticsearch is running. The default is localhost.No
--elasticsearch-portThe port for incoming HTTP requests. The default is 9200.No
--elasticsearch-index-prefixA prefix that identifies the Elasticsearch index. The default is magento2.No
--elasticsearch-timeoutThe number of seconds before the system times out. The default is 15.No
--elasticsearch-enable-authEnables authentication on the Elasticsearch server. The default is false.No
--elasticsearch-usernameThe user ID to authenticate ElasticsearchNo, unless authentication is enabled
--elasticsearch-passwordThe password to authenticate ElasticsearchNo, unless authentication is enabled

RabbitMQ configuration options:

Magento 2 Xampp Installation Manual Pdf

NameValueRequired?
--amqp-hostDo not use the --amqp options unless you have already set up an installation of RabbitMQ. See RabbitMQ installation for more information about installing and configuring RabbitMQ.
The hostname where RabbitMQ is installed.
No
--amqp-portThe port to use to connect to RabbitMQ. The default is 5672.No
--amqp-userThe username for connecting to RabbitMQ. Do not use the default user guest.No
--amqp-passwordThe password for connecting to RabbitMQ. Do not use the default password guest.No
--amqp-virtualhostThe virtual host for connecting to RabbitMQ. The default is /.No
--amqp-sslIndicates whether to connect to RabbitMQ. The default is false. See RabbitMQ for information about setting up SSL for RabbitMQ.No
--consumers-wait-for-messagesShould consumers wait for a message from the queue? 1 - Yes, 0 - NoNo

Lock configuration options:

NameValueRequired?
--lock-providerLock provider name.
Available lock providers: db, zookeeper, file.
The default lock provider: db
No
--lock-db-prefixThe specific db prefix to avoid lock conflicts when using db lock provider.
The default value: NULL
No
--lock-zookeeper-hostHost and port to connect to Zookeeper cluster when you use zookeeper lock provider.
For example: 127.0.0.1:2181
Yes, if you set --lock-provider=zookeeper
--lock-zookeeper-pathThe path where Zookeeper will save locks.
The default path is: /magento/locks
No
--lock-file-pathThe path where file locks will be saved.Yes, if you set --lock-provider=file

Consumers configuration options:

NameDescriptionValueRequired
--consumers-wait-for-messagesDetermines if consumers will wait for a message from the queue.1 - Yes, 0 - NoNo
  • 0: Consumers process available messages in the queue, close the TCP connection, and terminate. Consumers do not wait for additional messages to enter the queue, even if the number of processed messages is less than the --max_messages value specified during starting consumers.

  • 1: Consumers continue to process messages from the message queue until reaching the maximum number of messages (the value specified for --max_messages on the queue:consumers:start command) before closing the TCP connection and terminating the consumer process. If the queue empties before reaching --max_messages the consumer waits for more messages to arrive. If you use workers to run consumers instead of using a cron job, set this variable to 1.

The --consumers-wait-for-messages option is a global option and cannot be configured separately for each consumer.

To enable or disable modules after installing Magento, see Enable and disable modules.

What is sensitive data?

Magento uses your encryption key to encrypt the following:

  • Credit card information
  • Usernames and passwords specified in the Magento Admin configuration (for example, logins to payment gateways)
  • CAPTCHA values sent over the network

Magento does not encrypt:

  • Administrative and customer usernames and passwords (these passwords are hashed)
  • Address
  • Phone number
  • Other types of personally identifiable information except for credit card numbers

Sample localhost installations

The following examples show the commands to complete install Magento Commerce locally with various options.

Example 1—Basic installation with admin user account

The following example installs Magento with the following options:

  • The Magento software is installed in the magento2 directory relative to the web server docroot on localhost and the path to the Magento Admin is admin; therefore:

    Your storefront URL is http://127.0.0.1

  • The database server is on the same host as the web server.

    The database name is magento, and the username and password are both magento

  • Uses server rewrites

  • The Magento administrator has the following properties:

    • First and last name are Magento User
    • Username is admin and the password is admin123
    • E-mail address is [email protected]
  • Default language is en_US (U.S. English)
  • Default currency is U.S. dollars
  • Default time zone is U.S. Central (America/Chicago)
  • Elasticsearch 7 is installed on es-host.example.com and connects on port 9200

Messages similar to the following display to indicate a successful installation:

Example 2— Basic install without admin user account

You have the option to install Magento without creating the Magento administrator user as shown in the following example.

Messages like the following display if the installation is successful:

After installation you can create an admin user using the admin:user:create command:Create or edit an administrator

Example 3—Install with additional options

Magento 2 Install Theme

The following example installs Magento with the following options:

  • The Magento software is installed in the magento2 directory relative to the web server docroot on localhost and the path to the Magento Admin is admin; therefore:

    Your storefront URL is http://127.0.0.1

  • The database server is on the same host as the web server.

    The database name is magento, and the username and password are both magento

  • The Magento administrator has the following properties:

    • First and last name are Magento User
    • Username is admin and the password is admin123
    • E-mail address is [email protected]
  • Default language is en_US (U.S. English)
  • Default currency is U.S. dollars
  • Default time zone is U.S. Central (America/Chicago)
  • The installer first cleans up the database before installing the tables and schema
  • You use a sales order increment prefix ORD$ and because it contains a special character ($), the value must be enclosed in double quotes
  • Session data is saved in the database
  • Uses server rewrites
  • Elasticsearch 7 is installed on es-host.example.com and connects on port 9200

You must enter the command either on a single line or, as in the preceding example, with a character at the end of each line.

Messages like the following display if the installation is successful:

Related topics

Magento 2 Xampp Installation Instructions

  • If you have one user account to access the Magento server, see Optionally set a umask.

    This type of setup is typical for shared hosting.

  • Verify the installation.