Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shashanksrivatsarao/attendanceapp
This is a fully managed attendance management system I built for my DBMSmini Project
https://github.com/shashanksrivatsarao/attendanceapp
ajax apache2 aws-ec2 css html javascript mysql-database php readme
Last synced: 8 days ago
JSON representation
This is a fully managed attendance management system I built for my DBMSmini Project
- Host: GitHub
- URL: https://github.com/shashanksrivatsarao/attendanceapp
- Owner: ShashankSrivatsaRao
- Created: 2024-11-26T11:20:07.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-23T08:11:54.000Z (10 days ago)
- Last Synced: 2024-12-23T08:29:08.728Z (10 days ago)
- Topics: ajax, apache2, aws-ec2, css, html, javascript, mysql-database, php, readme
- Language: PHP
- Homepage: https://github.com/ShashankSrivatsaRao/attendanceapp
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Attendance Management System
This project is an **Attendance Management System** built using **PHP**, **MySQL**, and **Apache** on an EC2 instance. It allows users to manage student attendance, track roll numbers, and save them in a database. The system consists of a backend that interacts with MySQL, providing a seamless experience for managing attendance data.
### Features:
- Create and manage student details.
- Record and track student attendance.
- Easy integration with MySQL for database operations.
- Provides a clear, user-friendly interface.### Prerequisites:
- **Apache** Web Server
- **MySQL** Database
- **PHP** installed on EC2 instance---
## Deployment Steps on EC2 Instance
1. **Launch an EC2 instance** with **Ubuntu 20.04** and SSH into it.
2. **Update and install Apache, PHP, and MySQL**:
```bash
sudo apt update
sudo apt install apache2 php libapache2-mod-php mysql-server php-mysql3.**Clone this repository into the virtual machine using git clone command**.
```bash
git clone "url"
```4.Now check if the repo attendanceapp is there in the machine using ls command.Also check if or not the **apache** and the **mysql** server is running or not.
```bash
ls
sudo systemctl start apache2
sudo systemctl status apache2
sudo systemctl start mysql
sudo systemctl status mysql
```5.Create a database and set up user credentials:
```bash
sudo mysql -u root
CREATE DATABASE attendanceapp;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON attendanceapp.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```6.**Upload your project files to** /var/www/html/attendanceapp/ directory:
```bash
sudo cp -r /path/to/your/project/* /var/www/html/attendanceapp/
```7.**Now navigate to the**/var/www/html/attendanceapp file to see if all files have been copied.
**Set Correct file peermissions**
```bash
sudo chown -R www-data:www-data /var/www/html/attendanceapp
sudo chmod -R 755 /var/www/html/attendanceapp
```8.Now go into the database.php file in the attendanceapp/database foleder and set your database name , username and password as what you had set up in **Step5**
Replace the values with your EC2 MySQL database credentials:
```bash
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
```
***PLEASE NOTE THE ABOVE CODE IS NOT PRESENT IN MY DATABSE.PHP FILE INSIDE DATABASE FOLDER.IN THAT CODE JUST CHANGE THE CREDENTIALS OF THE DATABASE AND IT WILL WORK*****_9.MOST IMPORTANT STEP_** Now navigate into the attendanceapp/database/createtables.php folder and change the require once path to the path where the databse.php file is stored.This can be done by changing only the 4th line og the code like this .
```bash
conn->prepare($c);
try {
$s->execute([":tabname" => $tabName]);
} catch (PDOException $oo) {
// Handle exception
}
}
// Initialize Database connection
$dbo = new Database();
// SQL to create table
$c = "CREATE TABLE student_details (
id INT AUTO_INCREMENT PRIMARY KEY,
roll_no VARCHAR(20) UNIQUE,
name VARCHAR(50)
)";
// Execute query
$s = $dbo->conn->prepare($c);
try {
$s->execute();
echo("
student_details table created.");
} catch (PDOException $o) {
echo("
Error: student_details table not created.");
}
?>
```9.**Now run the following php command to create tables in the databse**
```bash
php createtables.php
```
***If you encounter any error it is beacase you have not provided the correct path to your database.php folder or have not entered the credentials correctly into the databse.php folder***10.Message saying all tables created is displayed.Now verify the tables are created by logging into the sql shell and checking the databse for tables using simple select query.
```bash
sudo mysql -u root -p
password:********
mysql>use database attendance;
mysql>show tables;
mysql>select * from faculty_details;
```11.Now Open the IP address of the EC2 instance in the browser and add /attendanceapp/login.php
12.Enter the login credentials username:rcb and password:123
# Modify the tables in createtables to suit your needs and use the project accordingly.
Youtube I referred to :https://www.youtube.com/playlist?list=PLJ4-ETiGBrdOZ4kvbzNGidD26M24BLImM
# Dockerizing this application using Docker
**To run this application, you must have Docker Desktop or Docker Engine installed on your system**
```
git clone https://github.com/ShashankSrivatsaRao/attendanceapp
cd attendanceapp
docker compose up --build
```
Now go to http://localhost and see the application use username:rcb and password :123
After everything run docker compose down# PROCESS
1. Analyze all the system dependencies , libraries ,files required to create a container image.
2. Write a Dockerfile to create a base image of the web server and install all the system dependencies.
```
FROM php:8.2-apache# Install system dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libonig-dev \
libxml2-dev \
zip \
curl \
unzip
# Install PHP extensions
RUN docker-php-ext-install mysqli pdo pdo_mysql mbstring exif pcntl bcmath gd
# Enable Apache modules
RUN a2enmod rewrite
# Configure Apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN sed -i 's/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/html\/attendanceapp/g' /etc/apache2/sites-available/000-default.conf
# Set working directory
WORKDIR /var/www/html/attendanceapp
# Copy application files
COPY . .
# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
# Configure PHP
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
```
3. Now that you have a docker file write a docker-compose.yml file to create 2 services web and db
```
version: '3.8'
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
volumes:
- .:/var/www/html/attendanceapp
depends_on:
- db
networks:
- attendance-network
db:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- "3307:3306"
environment:
- MYSQL_DATABASE=attendance
- MYSQL_USER=attendanceuser
- MYSQL_PASSWORD=Saswe@123
- MYSQL_ROOT_PASSWORD=root
volumes:
- mysql_data:/var/lib/mysql
networks:
- attendance-network
networks:
attendance-network:
driver: bridge
volumes:
mysql_data:
```
4.Now add a init.sql file to initialize the database and grant the user permissions.```
CREATE DATABASE IF NOT EXISTS attendance;
GRANT ALL PRIVILEGES ON attendance.* TO 'attendanceuser'@'%';
FLUSH PRIVILEGES;
```5.Now Run ```docker compose up --build ```