This is a sample e-commerce application built for learning purposes.
Here's how to deploy it on CentOS systems:
- Install FirewallD
sudo yum install firewalld
sudo service firewalld start
sudo systemctl enable firewalld
- Install MariaDB
sudo yum install mariadb-server
sudo vi /etc/my.cnf
sudo service mariadb start
sudo systemctl enable mariadb
- Configure firewall for Database
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
sudo firewall-cmd --reload
- Configure Database
$ mysql
MariaDB > CREATE DATABASE ecomdb;
MariaDB > CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword';
MariaDB > GRANT ALL PRIVILEGES ON *.* TO 'ecomuser'@'localhost';
MariaDB > FLUSH PRIVILEGES;
ON a multi-node setup remember to provide the IP address of the web server here:
'ecomuser'@'web-server-ip'
- Load Product Inventory Information to database
mysql < db-load-script.sql
- Install required packages
sudo yum install -y httpd php php-mysql
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --reload
- Configure httpd
Change DirectoryIndex index.html
to DirectoryIndex index.php
to make the php page the default page
sudo vi /etc/httpd/conf/httpd.conf
- Start httpd
sudo service httpd start
sudo systemctl enable httpd
- Download code
sudo yum install -y git
git clone https://github.com/kodekloudhub/learning-app-ecommerce.git /var/www/html/
- Update index.php
Update index.php file to connect to the right database server. In this case localhost
since the database is on the same server.
<?php
$link = mysqli_connect('172.20.1.101', 'ecomuser', 'ecompassword', 'ecomdb');
if ($link) {
$res = mysqli_query($link, "select * from products;");
while ($row = mysqli_fetch_assoc($res)) { ?>
ON a multi-node setup remember to provide the IP address of the database server here.
- Test
curl http://localhost