Installing Magento on Windows localhost can be a massive headache. As it does not support “officially” support the Windows platform. That’s pretty bad news for us Web Developers that are used to working on a Windows platform. But, of course, there’s still a way. If you are here because you need to set up a Magento development environment on Windows (error free), this guide is written specially for you! Note that this is for building a development environment on your local machine and not suitable for deployment.
For the uninitiated, Magento is a leading eCommerce software build with the Zend Framework, which Adobe acquired in 2018. Following the acquisition, Magento is offered as a cloud and licensed versions. But the community version is still available to download. According to Datanyze, as of March 2020, Magento market share in the eCommerce market is 3.96%.
Ok enough of background lets get on with it. In this guide on how to install magento 2 in localhost xampp, we will be using the Chrome Web browser on Windows 10. Let’s get started.
Magento Localhost installation Guide for Windows XAMPP
Firstly, understand that Magento requires specifically, Apache (or Nginx), PHP and MySql Database to run. We cannot use Windows IIS Server with PHP and MySql installed. Apache is a must in this case. Therefore, we must use a prepare a “LAMP” stack or in this case a “WAMP” stack localhost environment. In this case we choose to use XAMPP. XAMPP is a software that emulates a linux environment for your development with the dependencies PHP and MySql installed.
Step 1: Install XAMPP
Proceed to the XAMPP download page. As of writing, Magento 2.3X recommends using PHP version 7.3. So lets download the package marked as version 7.3.14 / PHP 7.3.14. Then, install the package by running the installation file.
We do not need FTP server, Tomcat server and Webalizer, so you can go ahead and uncheck those options. Next follow the on screen instructions to complete the installation.
Step 2: Start up the XAMPP Control Panel
Somehow my installation of XAMPP does not add the program to the start menu or Desktop icon. If you have a similar problem, locate the XAMPP installation folder you defined during the installation process. By default, it should be located at C:\XAMPP. Locate the file xampp-control.exe.
To avoid some pesky permission problems later on, always run XAMPP as Administrator when starting the program. You can do this by right-click to open the context menu and select “Run as Administrator“.
Start the Apache Service by clicking on the “Start” button indicated next to “Apache”. If you encounter problem with an error message similar below, don’t fret. It means that there is a conflicting application that is using ports 80 or port 443. You can resolve this by stopping the conflicting services. Usually, the offending application is Skype, IIS or Web Deploy. Close or stop these services from running and try again.
Step 3: Configure PHP.ini
Now we are going to setup the environment variables in PHP. To do so, click on Config in the control panel and choose “PHP (php.ini)”. This will launch notepad and open the php.ini settings file.
Here’s a few settings that you should do
Set the “memory_limit” variable to 2G. A lower memory causes Magento to slow down quite a fair bit. Giving a higher memory limit can resolve the slow Magento issue. Although Magento can still run at a lower memory limit, an extremely slow and clunky installation is a good waste of development time. So go ahead and set this up.
Find and uncomment the line “extension=intl” by removing the semi colon sign “;” in front of the line. Do the same for “extension=xsl”.
Save the changes and restart Apache by restarting the service. Magento requires MySql Service to run so let’s start MySQL as well.
At this point, you shouldn’t have any errors with Apache or MySql errors. Type “localhost” on your browser to check if services running fine.
Step 4: Set up a Database and user privileges
Next, we need to set up a database. From the dashboard, simply click on the phpMyAdmin link on the top bar.
From here click on “New” and then give the database a name. Click on “Create” to proceed. And Voila! Your database is created.
Note that the default user login is “root” and password is “<blank>”, as in no password. And since we are working on a local machine, there’s technically no need to create new user for our Magento install. But this irks me a little bit, so lets go create a new user and password.
Click on the User Accounts tab, scroll down and you’ll find the “Add User Account” Link.
Insert your preferred user name and passwords, as shown above. Scroll down and click on “Go” to complete the process. Do jolt or copy the password credentials somewhere as a reminder. You will need this information to install Magento.
Now, click on “Database” and select you Magneto Database and click on “Go”.
And Assign all privileges. Click “Go” to complete. Now lets go install Magento proper.
Step 5: Download Magento Community Version
Head to the Magento download page. There are 2 versions that you can choose. Firstly, the “Full Release (ZIP with no Sample Data)” Package or the “Full Release with Sample Data”. If you are new to Magento, the package with Sample Data can be very helpful to aid your development. Choose either package in the format you prefer. In our case we choose the Zip format, so that we do not have to additional software.
Next Create a project sub folder within the XAMPP htdocs folder. For example, c:/xampp/htdocs/magento. Unzip the contents of the installation package in this folder. This may take more than a few minutes there are tons of files to be extracted.
Step 6: Run the installation setup script
After extracting the package, run the install script by typing the installation address in your browser. For example, if you have extracted the package in c:/xampp/htdocs/magento, then your web address is http://localhost/magento.
Upon running the install, Magento presents you with a readiness check screen. This process checks if all the required PHP extensions and in properly set up. If you face any errors, go back to Step2 above and enable the corresponding extension.
Here, fill up the database credentials and details that we have created. If you did not create a new user, you can use “root” as username and “<blank>” as password.
Set up your store address and admin dashboard url next. And next, your preferred time zones, language and currency settings.
Note: It is recommended to use 127.0.0.1 to replace localhost to avoid errors.
Lastly, create your admin user account and run the install. Needless to say, please jolt down the credentials somewhere. The install will take about 15-20 mins in my experience, but varies for different systems.
Now the next step is crucial. Open the following file in Notepad.
Search for this line of code:
$realPath = $this->fileDriver->getRealPath($path);
Replace it with this line:
$realPath = str_replace("\\", "/", $this->fileDriver->getRealPath($path));
Now we are done with all the configuration needed to run Magento on Windows using Xampp.
Visit your store url and you will be greeted with the default installation.
Congratulations! you have successfully installed a local version of Magento on your workstation! We hope you find this guide to installing Magento on Windows insightful. At eadc, we offer in eCommerce Web Design services and WordPress Web Design at a competitive price. Contact us should you require a professional to help with your online retail business.