🗄ī¸Website Dynamic With PHP and MySQL Database

Introduction

PHP

PHP is a programming language that is commonly used in creating and developing websites. In fact, as reported by PHP.net, PHP is an abbreviation of PHP: Hypertext Preprocessor. According to the site, PHP is a widely used programming language and is especially suited to web development.

MySQL Database

MySQL is a relational database management system that uses SQL to carry out its functions. The main function of SQL is to create queries and operate database systems. MySQL allows analysts to handle, store, modify, delete and store data neatly.


Configuration EC2 Instance

SSH to Bastion Host

Use GitBash

cd Downloads
ssh-agent bash
ssh-add labsuser.pem
ssh -A -i [email protected]

Jump SSH to WebServer

Install Package

sudo -i
apt update && apt upgrade -y
apt install apache2 php php-mysql git mariadb-client -y

Exit From WebServer

exit (exit from root)
exit (exit from ssh webserver)

Jump SSH to DBInstance

Install Package

sudo -i
apt update && apt upgrade -y
apt install mariadb-server -y

Create Database

mysql -u root -p

create database dbwebcrud;
create user 'adminweb'@'%' identified by '123';
grant all privileges on *.* to 'adminweb'@'%';
flush privileges;
exit;

Edit Database

nano /etc/mysql/mariadb.conf.d/50-server.cnf

bind-address            = 127.0.0.1 (change to)
#bind-address           = 127.0.0.1

Restart mysql Service

systemctl restart mysql

Back to SSH WebServer

Delete file public_html

sudo -i
rm /var/www/html/index.html
cd /var/www/html

Clone repository github

git clone https://github.com/suryamsj/tutorial-crud-php-native.git /var/www/html/

Import Database From DBInstance

mysql -u [nama-user] –p[password] -h [ipaddress-db] [nama-database] < [path-ke-file.sql]
mysql -u adminweb -p123 -h 10.10.2.107 dbwebcrud < database/tutor_php.sql

Check For Database

mysql -u adminweb -p123 -h 10.10.2.107
use dbwebcrud;
show tables;

Edit File Connection PHP

nano function/connection.php

$hostname = "10.10.2.107";
$username = "adminweb";
$password = "123";
$database = "dbwebcrud";

Restart Apache2 Service

systemctl restart apache2 && systemctl status apache2

Configuration is Complete

Open Browser

[ip-pub-ec2-webserver]

"Daftar"
Nama : Rizwan Fairuz Mamduh
Username : rizwan29
Password : test123

Create Contact

Check Database

Check database from EC2 WebServer

mysql -u adminweb -p123 -h 10.10.2.107
show databases;
use dbwebcrud;
show tables;
select * from kontak;
select * from user;

Last updated