KodeKloud E-Commerce - Distributed

I’ve completed the distributed deployment on katacoda lab successfully and want to try same setup with vagrant on my laptop with multi-vm setup. Here is my Vagrantfile (centos7 is my custom Vagrant box, you can replace it with centos/7) to setup multi vms, one is db and another is the web server.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "centos7"
  config.vm.base_mac = nil

  config.vm.provider "virtualbox" do |vb|
    vb.memory = 1024
  end

  config.vm.define "db" do |db|
    db.vm.hostname = 'db'
    db.vm.network "private_network", ip: "192.168.56.20"
  end

  config.vm.define "web" do |web|
    web.vm.hostname = 'web'
    web.vm.network "private_network", ip: "192.168.56.21"
  end
end

On the db server, I installed MariaDB and configured as the same on katacoda lab:

$ yum install -y mariadb-server
$ systemctl enable mariadb
$ systemctl start mariadb
$ firewall-cmd --permanent --zone=public --add-port=3306/tcp
$ firewall-cmd --reload

Database setup:

CREATE DATABASE ecomdb;
CREATE USER 'ecomuser'@'%' IDENTIFIED BY 'ecompassword';
GRANT ALL PRIVILEGES ON *.* TO 'ecomuser'@'%';
FLUSH PRIVILEGES;

Also loaded data successfully: mysql < db-load-script.sql.

Then on web server, I installed httpd, php, php-mysql and configured as the same on katacoda lab.

$ yum install -y httpd php php-mysql
$ # change index.html in /etc/httpd/conf/httpd.conf to index.php
$ systemctl enable httpd
$ systemctl start httpd
$ firewall-cmd --permanent --zone=public --add-port=80/tcp
$ firewall-cmd --reload
$ git clone https://github.com/kodekloudhub/learning-app-ecommerce.git /var/www/html
$ # change db server IP address in index.php to 192.168.56.20

I opened the address 192.168.56.21 in Chrome and get a database connection error.

Did I miss something?

UPDATE: Found this Github issue and now my problem is solved. :grinning:

Hi @vancanhuit,
Thanks for sharing your knowledge…