Virtualisations and Cloud Infrastructure
Cover page
Table of contents
Proper headers
Screenshot references
Space for rationale, justification, verification
For reference:
1. Arch Linux Installation (on 40GB Virtual Disk): Steps for installation Arch Linux and disk Partition
Select iso and 40GB disk will create the VM:
After boot successful first verify the network connectivity:
Verify the internet connectivity:
Disk partition :
Using cfdisk, partition your disk as follows:
#lsblk
#cfdisk /dev/sda
Select Label Type:
Choose gpt for modern systems.
Create Partitions:
1. /boot - 512M
2. /home - 14G
3. / - 25.5G (remaining)
Write Changes: Confirm and write the partition table.
Format and Mount Partitions:
Format Partitions:
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3
Mount Partitions:
mount /dev/sda3 /mnt # Mount root
mkdir /mnt/{boot,home}
mount /dev/sda1 /mnt/boot # Mount boot
mount /dev/sda2 /mnt/home # Mount home
Then verify the disk :
#df –h
pacstrap /mnt base linux linux-firmware vim
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
pacstrap /mnt base linux linux-firmware sudo networkmanager
After verifying then you have to set the root password
Passwd
<enter password>
2.Secure the Root Account: Set strong password:
Passwd
Disable root login via SSH: Edit file /etc/ssh/sshd_config:
PermitRootLogin no
3.Create Admin Users
Groupadd IT
useradd -m -G IT anil
useradd -m -G IT ashley
passwd anil
passwd ashley
Enable sudo:
visudo
IT ALL=(ALL:ALL) ALL
4.Create Users & Set Permissions
# Create users
useradd -m avery
useradd -m evelynn
useradd -m james
# Set passwords
passwd avery
passwd evelynn
passwd james
4. Folder Setup: mkdir -p /srv/{http,dev}
# Avery: Full access to /srv
chown -R avery:avery /srv
chmod -R 770 /srv
# Evelynn: Access to /srv/http
chown -R evelynn:evelynn /srv/http
chmod -R 750 /srv/http
# Developers group for shared dev directory
groupadd developers
usermod -aG developers avery
usermod -aG developers evelynn
chown -R avery:developers /srv/dev
chmod -R 770 /srv/dev
# James: Read-only to /srv/dev
groupadd testers
usermod -aG testers james
chmod -R 750 /srv/dev
5. Setup SSH Server pacman -S openssh
systemctl enable sshd
systemctl start sshd
SSH configuration setup :
Install the package:
pacman –Sy openssh
Start the services :
Systemctl start ssh
Systemctl enable ssh
Check the IP address :
ip a
Then connect through the remote :
Edit /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication yes
AllowUsers anil ashley avery evelynn james
Restart SSH services:
systemctl restart sshd
6.Secure Dev Data Directory mkdir -p /srv/dev/project
chown -R avery:developers /srv/dev/project
chmod -R 770 /srv/dev/project
James (tester) will only have read access:
usermod -aG testers james
chmod -R 750 /srv/dev/project
7. Install Docker and Docker Compose genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
sudo pacman -S docker docker-compose
sudo systemctl enable docker –now
Give Access to Docker Only to Admins + Avery sudo groupadd docker
sudo usermod -aG docker anil # You
sudo usermod -aG docker ashley # IT Manager
sudo usermod -aG docker avery # Tech Lead
# Log out & log back in to apply group changes
Directory Setup sudo mkdir -p /srv/http # Website files
sudo mkdir -p /srv/docker/nginx # NGINX config
cd /srv/docker
Create docker-compose.yml vi docker-compose.yml
Paste this:
version: '3.8'
services:
mysql:
image: mysql:latest
container_name: mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: StrongPass123!
networks:
- backend
expose:
- "3306" # Not exposed to host
phpmyadmin:
image: phpmyadmin
container_name: phpmyadmin
restart: unless-stopped
environment:
PMA_HOST: mysql
networks:
- backend
nginx:
image: nginx:alpine
container_name: nginx
restart: unless-stopped
ports:
- "80:80"
volumes:
- /srv/http:/usr/share/nginx/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- backend
networks:
backend:
driver: bridge
Create NGINX Reverse Proxy Config
mkdir -p nginx
nano nginx/default.conf
Paste this:
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.php;
}
location /phpmyadmin {
proxy_pass http://phpmyadmin:80;
proxy_set_header Host $host;
}
}
Start Everything
cd /srv/docker
docker compose up -d