![](../images/magento2OnAWS.png)
Deployment of a Magento 2 Website on a Remote AWS Server
Installations can be tricky. While going through this installation myself, I had to uninstall and reinstall at least three times before getting to a successful installation with a working admin page. However, let me be clear that this is not the best practice for deploying a live ecommerce store. This is more of a learning tool to familiarize oneself with the installation process. Or, someone could use this as their the development environment to work on new features before deploying them live. Even so, this won’t cover setting up a virtual environment, which is important when developing applications for the masses. This is strictly covering the steps for local installation and deployment from a Windows machine.
This process consisted of:
Many of the issues I encountered arrived from installing the wrong software or the wrong version of the software. So, before I got through the entire installation, I had to uninstall and re-install several times, which was time consuming and I hope that this tutorial can save you that time. I am grateful I went through that however, because now I’m more familiar with how to check and verify a complete install/uninstall.
Also, these are the links to all the resources I used to get through the install:
Machine Specs:
As you can see the computer I used is nothing spectacular.
Some editing tools you might find useful:
Tech Stack
Side note: Magento2 is incompatible with PHP v. 8.0.12 so it’s very important to download the XAMPP package with the compatible version of PHP, that being PHP 7.4.25
Overall, when I timed myself while running through the third installation it took roughly 4 hours 52 minutes. However, that included writing and editing documentation and taking screenshots. So I wouldn’t consider the 4hr 52mins to be the standard time, but more like a benchmark to plan around in case you want to do try this installation yourself. After this section, starts the installation steps. Good luck, if you try it.
⇒ Click “Next >”
⇒ Click “Next >”
C:\xampp\php\php.ini
OR
Open up the XAMPP console > click on the “Config” button to the right of “Apache” > a selection box will appear and click on “PHP (php.ini)”
; extension = intl
; extension = soap
; extension = sockets
; extension = sodium
; extension = xsl
max_execution_time=120
max_input_time=60
memory_limit=512M
⇒ type: composer -v
⇒ Composer installation is verified with this resulting output:
https://www.elastic.co/downloads/elasticsearch
~\Downloads\elasticsearch-7.15.1-windows-x86–64\elasticsearch-7.15.1\bin
⇒ after right clicking on the file, then click:
“Run as Administrator”
⇒ a command-line should open — give it a moment to process
127.0.0.1:9200
OR
localhost:9200
⇒ a json output should render on the browser window w/ the elasticsearch installation details
⇒ if an error pops-up just wait a few moments for composer to finalize in the command-line window, then refresh the browser
It’s free and then you’ll be able to use the link below.
https://magento.com/tech-resources/download
magento.com
OR
from the magento github repo
C:\xampp\htdocs\magento2
⇒ extract contents of the magento zip file into the new folder you just created
Notice: this extraction takes a long time w/ or w/out sample data. For my computer, it took a little over 45 minutes and of course that will vary for everyone based on their computers and connections.
localhost/magento2
⇒ this is to verify a successful installation
⇒ make sure that Apache & MySQL are running on XAMPP before verifying
localhost/magento2
in the URL address barIf you received errors and did not see a set-up page then CONGRATULATIONS! You are like me. Please continue on for the rest of the steps to get to a working admin page
If you did not receive errors and did see a set-up page render, then I am truly impressed. Congratulations! but I have no further instructions.
mysqladmin.exe -u root password yourpassword
yourpassword
with the password you want to use. I put root
as my passwordC:\xampp\phpMyAdmin\config.inc.php
by clicking on the “Explorer” button on the XAMPP Control Panel and navigating the file browserconfig.inc.php
, open it up with Notepad and insert your new password where the red arrow is pointing in the screenshot, below. There’s another screenshot immediately after the first one that zooms in on the block of lines that contain the password config line. Use the password you just created in the command-line after you clicked on the “Shell” button in the XAMPP Control Panel.Magento is served from /var/www/html/magento2/pub
. However, the rest of the file system is vulnerable because it is accessible from the browser. Therefore we’ll set the webroot to the pub/
directory in order to prevent site visitors from accessing sensitive areas of the file system from the browser.
pub/
by going to the file C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/magento2/pub" ServerName yourname.magento.com </VirtualHost><VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost>
… like in the screenshots below
C:\Windows\System32\drivers\etc\hosts
file in notepadhosts
file won’t appear in the file browser so you have to change the file extension filter from .txt to All fileshosts
file (it’s an extensionless file) and add the following line at the bottom of the file:127.0.0.1 yourname.magento.com
… like in the screenshot below:
We’re now ready to configure magento to our server and host configurations
cd C:\xamp\htdocs\magento2
php bin/magento setup:install — base-url=”http://yourname.magento.com/" — db-host=”localhost” — db-name=”magento2" — db-user=”root” — db-password=”root” — admin-firstname=”admin” — admin-lastname=”admin” — admin-email=”user@example.com” — admin-user=”admin” — admin-password=”Admin@123456" — language=”en_US” — currency=”USD” — timezone=”America/Chicago” — use-rewrites=”1" — backend-frontname=”admin” — search-engine=elasticsearch7 — elasticsearch-host=”localhost” — elasticsearch-port=9200
Replace these values if necessary:
The other values are not important for installation, and can be changed later.
Now if everything is done properly, Composer will start to install Magento 2.
Error :
In PatchApplier.php line 170:
Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file
In Gd2.php line 72: Wrong file
Solution:
Here, Image Adapter is trying to open the image files (‘open function in Gd2.php line 72). The validateURLScheme
function always returns false because it is checking for URL format but local files fall under this type of format, so it returns false.
Find validateURLScheme function in vendor\magento\framework\Image\Adapter\Gd2.php file. at line 94. Replace function with this:
private function validateURLScheme(string $filename) : bool
{
$allowed_schemes = [‘ftp’, ‘ftps’, ‘http’, ‘https’];
$url = parse_url($filename);
if ($url && isset($url[‘scheme’]) && !in_array($url[‘scheme’], $allowed_schemes) && !file_exists($filename)){
return false;
}
return true;
}
&& !file_exists($filename)
text added at line 98.php bin/magento setup:install — base-url=”http://yourname.magento.com/" — db-host=”localhost” — db-name=”magento2" — db-user=”root” — db-password=”root” — admin-firstname=”admin” — admin-lastname=”admin” — admin-email=”user@example.com” — admin-user=”admin” — admin-password=”Admin@123456" — language=”en_US” — currency=”USD” — timezone=”America/Chicago” — use-rewrites=”1" — backend-frontname=”admin” — search-engine=elasticsearch7 — elasticsearch-host=”localhost” — elasticsearch-port=9200
Now if you go to your browser with this URL to access Magento 2 store: http://yourname.magento.com .You will probably see a blank page like this
Solution:
C:\xampp\htdocs\magento2\vendor\magento\framework\View\Element\Template\File
$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace(‘\\’, ‘/’, $this->fileDriver->getRealPath($path));
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
and replace with
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Next, you will need to run the following commands to update the database and deploy static view files
php bin/magento indexer:reindex
php bin/magento setup:upgrade
… give it a moment
php bin/magento setup:static-content:deploy -f
… again, give it a moment
php bin/magento cache:flush
php bin/magento catalog:images:resize
http://yourname.magento.com/admin
Solution:
C:\xampp\htdocs\magento2
directory, and run this command:php bin/magento module:disable Magento_TwoFactorAuth
This command will disable the Two-Factor Authorization requirement so you won’t see the error message when logging-in again.
You should now be able to access the admin page and it should look similar to this:
You made it to the finish line and you now have a working installation of the Magento 2 platform served from the localhost of a Windows machine
If you enjoyed reading this article, support my writing by signing up for a Medium subscription.
Medium is a writing platform where writers from all over the world showcase their writing, covering any topic you can think of.
With a subscription you'll have unlimited access to all these writers and email notifications for my newly posted articles.
...but never fear, if you really enjoy my cybersecurity articles, then they will always be available here to read for free, for you!