We don’t live in a Linux Universe, not yet. As we are developers operating mainly from windows, there are some advantages you can gain, mostly game-wise. But there are major disadvantages, too.
These disadvantages are: having to sacrifice performance for virtualization as you try to use Virtual Box or Hyper-V to install a fully-fledged Linux System. Then, dealing with the Networking issues. Last but not the least, some problems with re-configure things on other devices.
We aren’t going to fix that, not entirely anyway. What we are trying to do in this tutorial is installing all-in software platform on your windows machine with main advantages:
- Low download sizes
- Minimal configuration on the networking side
- Faster performance in the future with no change in networking or additional configuration
This is achieved by using Windows own Linux terminal. Well, not just terminal but a Linux Kernel installed in its system named WSL (Windows Subsystem for Linux).
- WSL (Windows Subsystem for Linux)
WSL (Windows Subsystem for Linux)
When the next windows version released (at the time of writing this it’s version 1903 Build Number 18990), It would be version 2 which improves IO performance drastically.
WSL is fairly new idea introduced in Windows 10 build number 16215 which is version 1607.
The main idea here is that you can use open source terminal software in Linux kernel with download size that is less than 250 MB.
You can start the “Linux System” just like a normal app. And install all your tools from it and use the system resources through the link “localhost” just like any windows service.
Software developed by the Spryker team. It operates mainly in Germany and has a very large code “modules” reached 750 modules (at the time of writing this) which is used for E-Commerce objectives.
It has two suites totally; the shop suit and the Commerce OS suite which is directed to the banking systems.
This based mainly on Spryker Installation Requirements.
- MySQL/PostgreSQL: Installed on the Windows which both is easier and performs better
- Jenkins: Again, on Windows, same reasons
- RabbitMQ: Windows
- Redis for Windows installed from here or you can use the subsystem, either way it’s fine.
- ElasticSearch: you should use version 5 for Spryker to work, download it from here. Installed on windows.
- Graphviz: Windows
- NodeJS: on the subsystem
- NPM: installed separately on the subsystem.
- Nginx: subsystem install
Here is where the magic happens.
There are three main steps to do here:
- Enable Windows Subsystem in your Windows:
a. Search for “Features”
b. Go to “Turn Windows features on or off”
c. Enable the Following:
i. Windows Hypervisor Platform
ii. Virtual Machine Platform (WSL 2 Required)
iii. Windows Subsystem for Linux
- Install WSL
a. Go to “Microsoft Store”
b. Search For “Kali”
c. The Linux group shows, install Kali/Debian
This is because Ubuntu at the time of writing this supports up to PHP 7.2 FPM, Kali Supports PHP 7.3 without additional apt setup.
- Run the Subsystem and assign a password for the installation to finish.
Installing Tools for WSL & Windows
Tools for Windows
Let’s start with databases: we tested the system with MySQL.
- Download MySQL from here. We tested with V8 but the system Spryker works just fine with 5.7 and higher.
- Make sure it works on the default port of 3306 and that it uses the standard authentication type.
- use the host ip 0.0.0.0 in my.ini in the installation folder.
- Add a new user named “development”, a DBA with the password of “mate20mg” and write them down when changing because it will be necessary later while configuring Spryker.
- Download from here
- Install it to run on port 10007 this is important, otherwise remember the port, you will need it later when configuring Spryker.
- Go to http://localhost:10007
- Follow the instruction and complete the download
- Now it’s done.
- Download from here. Note: DO NOT Use the 7 version, simply it won’t work with Spryker. If you want to use it for your own project, it will work perfectly.
- Go to the installation folder, then to the config file “elasticsearch.yml”
- Edit the port number next to “http.port” and make it 10005.
- Start from “…/bin/elasticsearch.bat”.
Here we have 2 options; I tested the windows approach but in theory they are both easy and good.
- Windows approach:
- Download Redis from windows from here.
- Start the installation but don’t forget to specify the port to be 10009.
- Subsystem approach is described in the subsystem section.
- Download from here.
- Standard installation, nothing to configure here.
Tools for WSL
Download PostgreSQL, it depends basically on your distro. Command:
“apt install postgresql”.
- No need for erlang
- Install using this command
“apt install rabbitmq-server”.
Since we will be editing a lot of stuff here, let’s start with installing the code editor.
- Execute the command
“apt install vim”
- Voila, you have it
I have installed Kali because it supports) PHP 7.3 by default (at the time of writing this. That’s why I’m going to use it. If you use another version of PHP, change the number, accordingly.)
- Execute the command
“apt install php-fpm”
- And then this command:
“apt-get install php-curl php-jsonphp-mysql php-pdo-sqlite php-sqlite3 php-gd php-intl php-mysqli php-pgsql php-ssh2 php-gmp php-mcrypt php-pdo-mysql php-readline php-twig php-imagick php-memcache php-pdo-pgsql php-redis php-xml php-bz2 php-mbstring”
- Go the php config located in /etc/php/7.3/fpm
- Enable the following extensions:
- extension= bz2
- extension= curl
- extension= fileinfo
- extension= gd2
- extension= gettext
- extension= gmp
- extension= intl
- extension= imap
- extension= interbase
- extension= ldap
- extension= mbstring
- extension= exif ; Must be after mastering as it depends on it
- extension= mysqli
- extension= openssl
- extension= pdo_mysql
- extension= pdo_pgsql
- extension= pdo_sqlite
- extension= pgsql
- extension= redis.so
To start the service, execute:
“service php7.3-fpm start”
- Spryker uses Node V8, Not 10 nor 12. Trust me, I’ve tried.
- To install download the file from here. What you are looking for is linux-x64.tar.gz
- Copy the file into ~ directory:
“cp /mnt/c/…/node***.gz ~” while ***means to complete the name of the file.
- Extract using the command
“sudo tar -xJvf node-***.gz -C /usr/local/lib/nodejs”
- To commit the Path change open the file
“~/.bashrc”and add the following: PATH=/usr/local/lib/nodejs/node-v8***/bin:$PATH
- export PATH
- replace *** with the full folder name.
Restart wsl, and try
Installed with Node
Execute the following command:
“apt install nginx”
GIT for linux
Yeah yeah, you figured it out. This command:
“apt install git-all”
Configuring Tools for WSL & Windows
PostgreSQL Configuring for WSL
After Downloading PostgreSQL using the command:
“apt install postgresql”, follow these two steps for configuring:
- Start PostgreSQL service. Command:
“service postgresql start”.
- No need to install any users.
RabbitMQ Configuring for Windows
- Enable administration plugin
- Go to installation location.
- Run PowerShell/ CMD there: you can do it by holding “shift” while pressing right click.
- Type the command
“rabbitmq-plugins.bat enable rabbitmq_management”
- Go to http://localhost:15672
- Use username “guest” and password “guest”
- Go to admin tab
- Go to virtual hosts and add the following
- The final product should be something like this
- Go to users and add the following
- “AT_development” as “management”
- “DE_development” as “management”
- “US_development” as “management”
- “admin” as “administrator”
- Go to each user and assign the appropriate virtual host like: US_development > US_development_zed
- Add all the virtual hosts to the user admin
- The final product should be something like this
It was really a surprise to me how complex these configurations can get. Basically, you have a config folder that takes control of all the connections the platform needs. But the thing is, it’s configured in a way that prevent windows from running the thing no matter what. However, since we have a Linux kernel working for us let’s dig in.
The process goes like this:
- Clone the B2C/B2B suite.
- Composer install it. Based on the HDD/SSD speed you have and the internet speed this is gonna take a while.
- Config the platform.
- Install the platform.
- Config the Nginx
- The platform is installed, congrats.
OK, strap in, we start:
Clone the repo
Again, we have two options, either we use our basic windows drive, or we use the Linux one, I would recommend using Linux, since it uses optimized VHD disks images in the version 2. But I will describe both options.
Windows disk approach
This gives us advantage of licensing the editor we use. Since we are describing this tuts for Windows users they have licensed (or not 😊, i.e. they use VS Code) code editor software.
So, I shall clone the repo to “E:\Spryker” path.
The PowerShell script goes like this: (put in code area)
- Wait for 200 MB to download without interruption and that’s it
- This exact folder is located in the Linux kernel in the path “/mnt/e/Spryker” and will be used when configuring Nginx.
WSL disk approach
Ok, we start by creating the root directory for our site, and we config Nginx to use it. (put in code area)
“Mkdir -p /var/www/Spryker/”
4. Wait for 200 MB to download uninterrupted, and you got it
Downloading the full platform
Basically, this is the easiest part of this. But before you do that remember to use the command “ulimit -n 65535”. You just got to go to the installation directory and execute the command “composer install”, additional extensions may be required, just enable it and you’re ok.
Configuring the platform
Ok, now we should start moving some stuff from inside the platform:
- Switch to MySQL (Optional)
- Correct RabbitMQ Links
- Correct Other Links
Switching to mysql (optional)
The file we are looking for is located in the path: “…/config/Shared/config_default-development.php”
Change every “localhost” to “127.0.0.1” since MySQL doesn’t connect using “localhost”.Then change ZED_DB_PORT from 5432 to 3306, and change every PropelConstants::ZED_DB_ENGINE_PGSQL to PropelConstants::ZED_DB_ENGINE_MYSQL.
Correct RabbitMQ links h3
It’s very important to Remove the “/” from every RABBITMQ_CONNECTION_NAME
I downloaded the project in the directory /var/www/Spryker.loc, if you choose another folder, then change accordingly. The full files shall be available from here.
Spryker config Files Corrected
You can download from here.
Initiating the System
We need 3 steps here:
- Installing npm dependencies: “npm I” on the project root
- Starting the services from Windows and WSL
- Service postgresql start
- Service rabbitmq-server start (If on WSL)
- Service redis-server start (if on WSL)
- Service php7.3-fpm start
- Service nginx start
- Make sure Jenkins is working on Windows
- Make sure Elasticsearch 5 is working on Windows
- Initiate installation by executing vendor/bin/install -r development
Generating New Module
Type this command:
“vendor/bin/console code:generate:module:yves HelloWorld” and voila it works.
Almost every error will happen right now, is IP related, so just change the IP from the config and the system should operate well.
- Relatively low Performance with TLE form almost every connection on WSL, this is due to IO lag, improved on WSL2 to a good state (requests on zed takes 3-8 secs depending on complexity).
- Network issues due to changing IP addresses for every reboot. It was fixed with me by installing VirtualBox and using 10.10.0.1 as a primary IP for connections.