Project - E-commarce Web Application


LAMP stack application
Deployed on Linux with Apache server that uses MySQL Database and a PHP programming language.
We will use MariaDB instead of MySQL. MariaDB is a community fork of MySQL, and they are very much similar.
Step 1
Identify a system, on which we will deploy the application.
- It’s going to be Linux and we will use a CentOS machine
Step 2
Install and configure the Apache httpd server
Enable and start the service
Step 3
Install and configure MariaDB database
Enable and start the database services
Step 4
Install and configure PHP on the server
Download all the source code for our application, and configure it to work with Apache and PHP
In addition to these, we will make sure we have any other system requirements configured correctly, such as install and configure firewall on our server. Creating necessary rules to enable communications between these etc.
Reordering the tasks to better flow
Step 1
Installing firewalld
sudo yum install firewalld
installing firewalld
sudo service firewalld start
start the firewalld service
sudo systemctl enable firewalld
Enable the firewalld service
sudo firewall-cmd --list-all
to see all the firewall rules
Step 2
Installing MariaDB database
sudo yum install mariadb-server
install MariaDB server
sudo vi /etc/my.cnf
configuring the configuration file with right port settings.
sudo service mariadb start
starting mariadb service
sudo systemctl enable mariadb
enable mariadb service
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
adding the firewall rule to enable access to SQL port 3306
sudo firewall-cmd --reload
reloading the firewall rule to apply the rule
Go into the database using mysql
command line utility and need to create the ecomdb database. Then need to create the ecom user and flush privileges.
mysql < db-load-scripts.sql
Then need to load the inventory data about the products to the database.
Step 3
Installing required packages for the web server
sudo yum install -y httpd php php-mysql
to connect php to MySQL
sudo firewall-cmd --permanent --zone=public --add-poet=80/tcp
adding the firewall rule for allowing external access to port 80
sudo firewall-cmd --reload
sudo vi /etc/httpd/conf/httpd.conf
to configure httpd to use index.php instead of index.html
sudo service httpd start
start the service
sudo systemctl enable httpd
enable the service
Install git (if not present in system) then download the php code from git to the required directory, and test it using curl.
To make the deployment model on a multinode setup, we can set up the database on one node and the webserver on another node. To do so, we need to add webserver’s IP on the database node to make the database accessible from the webserver and similarly need to add the database’s IP to webserver’s code.
Resource
Subscribe to my newsletter
Read articles from Arindam Baidya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
