Tools: Docker commands
📌 Table of Contents
1. Hosting Apache2 — Traditional Way
Install Apache2
Start, Enable & Check Status
Web Root — where your files go
Deploy your page
Fix Permissions (always do this!)
Test config & Reload
2. Hosting Nginx — Traditional Way
Install Nginx
Deploy your page
Test config & Reload
Port Conflict — Apache & Nginx both want port 80
3. Multiple Static Sites
Apache — Virtual Hosts
Nginx — Server Blocks
4. Hosting via Docker
Nginx via Docker — Single Site
Host your own HTML file inside Docker
Apache via Docker
Multiple Sites via Docker (different ports)
5. Clone from GitHub & Host via Docker
Method 1 — Clone & Mount with Docker
Method 2 — Clone & Host with Apache
Method 3 — Clone & Host Normally (Without Docker)
6. Bash Scripting — Automate Everything
Script Skeleton (always start with this)
Variables & User Input
Special Variables
If / Else
Case Statement — Handle Flags
For Loop
Heredoc — Write Multi-line Files
Redirect Operators
Full Script — Auto Deploy Site from GitHub
Full Script — Setup Apache Virtual Host
7. Docker Cheatsheet
Images
Containers — Run
Volume Mount
Containers — Manage
Enter a Running Container
Cleanup — All at Once
Useful Flags Reference
8. Key Concepts & Golden Rules
File Locations — Never Forget
Permissions — The Rules
systemctl Commands
Apache vs Nginx — Quick Comparison
Pipe vs Redirect — Common Mistakes
Docker: attach vs exec
GitHub + Docker — The DevOps Workflow
🎯 Quick Reference Card A practical, terminal-focused guide covering everything you need to know about web server deployment, Docker containers, GitHub-based hosting, and Bash automation. Visit: http://localhost ✅ Each site gets its own folder and config file. Create config file for Site 1: Create config file for Site 2: Add fake DNS to /etc/hosts: Visit http://site1.local and http://site2.local ✅ Create config for Site 1: Enable sites using symlinks (no a2ensite in Nginx!): Key Difference: Apache uses a2ensite command. Nginx uses manual ln -s symlinks. Visit http://localhost:8080 ✅ Important: Nginx's web root inside Docker is /usr/share/nginx/html/ — NOT /var/www/html/ Visit http://localhost:8081 and http://localhost:8082 ✅ This is the real-world DevOps workflow — pull code from GitHub, host it instantly with Docker. Visit http://localhost:8080 — your GitHub site is live! ✅ Key difference: Apache Docker container uses /var/www/html as web root, Nginx uses /usr/share/nginx/html Make it executable and run: That's it. 3 commands. Site is live. ✅ Written for CS316 DevOps — Practical Lab Reference Guide
Topics: Apache2 | Nginx | Docker | Bash Scripting | GitHub Deployment Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse
$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
/var/www/html/
/var/www/html/
/var/www/html/
echo "<h1>My Apache Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
echo "<h1>My Apache Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
echo "<h1>My Apache Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/
-weight: 600;">sudo apache2ctl -t # test for syntax errors → should say: Syntax OK
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo apache2ctl -t # test for syntax errors → should say: Syntax OK
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo apache2ctl -t # test for syntax errors → should say: Syntax OK
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx
echo "<h1>My Nginx Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
echo "<h1>My Nginx Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
echo "<h1>My Nginx Site</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
-weight: 600;">sudo nginx -t # should say: syntax is ok
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo nginx -t # should say: syntax is ok
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo nginx -t # should say: syntax is ok
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo lsof -i :80 # see who owns port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # free port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx # now nginx can -weight: 500;">start
-weight: 600;">sudo lsof -i :80 # see who owns port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # free port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx # now nginx can -weight: 500;">start
-weight: 600;">sudo lsof -i :80 # see who owns port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # free port 80
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx # now nginx can -weight: 500;">start
# Step 1 — Create site folders
-weight: 600;">sudo mkdir -p /var/www/site1
-weight: 600;">sudo mkdir -p /var/www/site2 # Step 2 — Create HTML pages
echo "<h1>Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html # Step 3 — Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
# Step 1 — Create site folders
-weight: 600;">sudo mkdir -p /var/www/site1
-weight: 600;">sudo mkdir -p /var/www/site2 # Step 2 — Create HTML pages
echo "<h1>Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html # Step 3 — Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
# Step 1 — Create site folders
-weight: 600;">sudo mkdir -p /var/www/site1
-weight: 600;">sudo mkdir -p /var/www/site2 # Step 2 — Create HTML pages
echo "<h1>Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html # Step 3 — Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
-weight: 600;">sudo nano /etc/apache2/sites-available/site1.conf
-weight: 600;">sudo nano /etc/apache2/sites-available/site1.conf
-weight: 600;">sudo nano /etc/apache2/sites-available/site1.conf
<VirtualHost *:80> ServerName site1.local DocumentRoot /var/www/site1 ErrorLog ${APACHE_LOG_DIR}/site1_error.log CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
<VirtualHost *:80> ServerName site1.local DocumentRoot /var/www/site1 ErrorLog ${APACHE_LOG_DIR}/site1_error.log CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
<VirtualHost *:80> ServerName site1.local DocumentRoot /var/www/site1 ErrorLog ${APACHE_LOG_DIR}/site1_error.log CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
-weight: 600;">sudo nano /etc/apache2/sites-available/site2.conf
-weight: 600;">sudo nano /etc/apache2/sites-available/site2.conf
-weight: 600;">sudo nano /etc/apache2/sites-available/site2.conf
<VirtualHost *:80> ServerName site2.local DocumentRoot /var/www/site2
</VirtualHost>
<VirtualHost *:80> ServerName site2.local DocumentRoot /var/www/site2
</VirtualHost>
<VirtualHost *:80> ServerName site2.local DocumentRoot /var/www/site2
</VirtualHost>
-weight: 600;">sudo a2ensite site1.conf
-weight: 600;">sudo a2ensite site2.conf
-weight: 600;">sudo a2dissite 000-default.conf # -weight: 500;">disable default site
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo a2ensite site1.conf
-weight: 600;">sudo a2ensite site2.conf
-weight: 600;">sudo a2dissite 000-default.conf # -weight: 500;">disable default site
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo a2ensite site1.conf
-weight: 600;">sudo a2ensite site2.conf
-weight: 600;">sudo a2dissite 000-default.conf # -weight: 500;">disable default site
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
-weight: 600;">sudo nano /etc/hosts
# Add these lines:
127.0.0.1 site1.local
127.0.0.1 site2.local
-weight: 600;">sudo nano /etc/hosts
# Add these lines:
127.0.0.1 site1.local
127.0.0.1 site2.local
-weight: 600;">sudo nano /etc/hosts
# Add these lines:
127.0.0.1 site1.local
127.0.0.1 site2.local
-weight: 600;">sudo mkdir -p /var/www/site1 /var/www/site2
echo "<h1>Nginx Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Nginx Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
-weight: 600;">sudo mkdir -p /var/www/site1 /var/www/site2
echo "<h1>Nginx Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Nginx Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
-weight: 600;">sudo mkdir -p /var/www/site1 /var/www/site2
echo "<h1>Nginx Site 1</h1>" | -weight: 600;">sudo tee /var/www/site1/index.html
echo "<h1>Nginx Site 2</h1>" | -weight: 600;">sudo tee /var/www/site2/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/site1 /var/www/site2
-weight: 600;">sudo chmod -R 755 /var/www/site1 /var/www/site2
-weight: 600;">sudo nano /etc/nginx/sites-available/site1
-weight: 600;">sudo nano /etc/nginx/sites-available/site1
-weight: 600;">sudo nano /etc/nginx/sites-available/site1
server { listen 80; server_name site1.local; root /var/www/site1; index index.html;
}
server { listen 80; server_name site1.local; root /var/www/site1; index index.html;
}
server { listen 80; server_name site1.local; root /var/www/site1; index index.html;
}
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site1 /etc/nginx/sites-enabled/
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site2 /etc/nginx/sites-enabled/
-weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site1 /etc/nginx/sites-enabled/
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site2 /etc/nginx/sites-enabled/
-weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site1 /etc/nginx/sites-enabled/
-weight: 600;">sudo ln -s /etc/nginx/sites-available/site2 /etc/nginx/sites-enabled/
-weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
# Pull image
-weight: 500;">docker pull nginx # Run with port mapping
-weight: 500;">docker run -d -p 8080:80 --name mysite nginx
# Pull image
-weight: 500;">docker pull nginx # Run with port mapping
-weight: 500;">docker run -d -p 8080:80 --name mysite nginx
# Pull image
-weight: 500;">docker pull nginx # Run with port mapping
-weight: 500;">docker run -d -p 8080:80 --name mysite nginx
echo "<h1>Hello Docker!</h1>" > index.html -weight: 500;">docker run -d -p 8080:80 \ --name mysite \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx
echo "<h1>Hello Docker!</h1>" > index.html -weight: 500;">docker run -d -p 8080:80 \ --name mysite \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx
echo "<h1>Hello Docker!</h1>" > index.html -weight: 500;">docker run -d -p 8080:80 \ --name mysite \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx
-weight: 500;">docker pull ubuntu/apache2
-weight: 500;">docker run -d --name webserver -p 8081:80 ubuntu/apache2
-weight: 500;">docker pull ubuntu/apache2
-weight: 500;">docker run -d --name webserver -p 8081:80 ubuntu/apache2
-weight: 500;">docker pull ubuntu/apache2
-weight: 500;">docker run -d --name webserver -p 8081:80 ubuntu/apache2
mkdir site1 site2
echo "<h1>Site 1</h1>" > site1/index.html
echo "<h1>Site 2</h1>" > site2/index.html -weight: 500;">docker run -d --name site1 -p 8081:80 \ -v $(pwd)/site1/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker run -d --name site2 -p 8082:80 \ -v $(pwd)/site2/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker ps # verify both running
mkdir site1 site2
echo "<h1>Site 1</h1>" > site1/index.html
echo "<h1>Site 2</h1>" > site2/index.html -weight: 500;">docker run -d --name site1 -p 8081:80 \ -v $(pwd)/site1/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker run -d --name site2 -p 8082:80 \ -v $(pwd)/site2/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker ps # verify both running
mkdir site1 site2
echo "<h1>Site 1</h1>" > site1/index.html
echo "<h1>Site 2</h1>" > site2/index.html -weight: 500;">docker run -d --name site1 -p 8081:80 \ -v $(pwd)/site1/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker run -d --name site2 -p 8082:80 \ -v $(pwd)/site2/index.html:/usr/share/nginx/html/index.html nginx -weight: 500;">docker ps # verify both running
# Step 1 — Clone your static site from GitHub
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site # Step 2 — Run Nginx container with your cloned folder mounted
-weight: 500;">docker run -d \ --name myapp \ -p 8080:80 \ -v $(pwd):/usr/share/nginx/html \ nginx # Step 3 — Verify
-weight: 500;">docker ps
# Step 1 — Clone your static site from GitHub
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site # Step 2 — Run Nginx container with your cloned folder mounted
-weight: 500;">docker run -d \ --name myapp \ -p 8080:80 \ -v $(pwd):/usr/share/nginx/html \ nginx # Step 3 — Verify
-weight: 500;">docker ps
# Step 1 — Clone your static site from GitHub
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site # Step 2 — Run Nginx container with your cloned folder mounted
-weight: 500;">docker run -d \ --name myapp \ -p 8080:80 \ -v $(pwd):/usr/share/nginx/html \ nginx # Step 3 — Verify
-weight: 500;">docker ps
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site -weight: 500;">docker run -d \ --name apacheapp \ -p 8081:80 \ -v $(pwd):/var/www/html \ ubuntu/apache2
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site -weight: 500;">docker run -d \ --name apacheapp \ -p 8081:80 \ -v $(pwd):/var/www/html \ ubuntu/apache2
-weight: 500;">git clone https://github.com/yourusername/your-static-site.-weight: 500;">git
cd your-static-site -weight: 500;">docker run -d \ --name apacheapp \ -p 8081:80 \ -v $(pwd):/var/www/html \ ubuntu/apache2
# Clone repo
-weight: 500;">git clone https://github.com/yourusername/your-site.-weight: 500;">git # Copy files to Apache/Nginx web root
-weight: 600;">sudo cp -r your-site/* /var/www/html/ # Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/ # Reload server
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
# OR
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
# Clone repo
-weight: 500;">git clone https://github.com/yourusername/your-site.-weight: 500;">git # Copy files to Apache/Nginx web root
-weight: 600;">sudo cp -r your-site/* /var/www/html/ # Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/ # Reload server
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
# OR
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
# Clone repo
-weight: 500;">git clone https://github.com/yourusername/your-site.-weight: 500;">git # Copy files to Apache/Nginx web root
-weight: 600;">sudo cp -r your-site/* /var/www/html/ # Fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/
-weight: 600;">sudo chmod -R 755 /var/www/html/ # Reload server
-weight: 600;">sudo -weight: 500;">systemctl reload apache2
# OR
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
#!/bin/bash
# Description: What this script does
# Usage: ./script.sh <argument> # your code here
#!/bin/bash
# Description: What this script does
# Usage: ./script.sh <argument> # your code here
#!/bin/bash
# Description: What this script does
# Usage: ./script.sh <argument> # your code here
chmod +x script.sh
./script.sh
chmod +x script.sh
./script.sh
chmod +x script.sh
./script.sh
#!/bin/bash
NAME="Daniyal" # variable — NO spaces around =
echo "Hello $NAME" read -p "Enter site name: " SITE # get input from user
echo "You entered: $SITE"
#!/bin/bash
NAME="Daniyal" # variable — NO spaces around =
echo "Hello $NAME" read -p "Enter site name: " SITE # get input from user
echo "You entered: $SITE"
#!/bin/bash
NAME="Daniyal" # variable — NO spaces around =
echo "Hello $NAME" read -p "Enter site name: " SITE # get input from user
echo "You entered: $SITE"
./deploy.sh site1 8080
# $1 = site1, $2 = 8080, $# = 2
./deploy.sh site1 8080
# $1 = site1, $2 = 8080, $# = 2
./deploy.sh site1 8080
# $1 = site1, $2 = 8080, $# = 2
#!/bin/bash
if [ -z "$1" ]; then echo "Error: No argument given" echo "Usage: ./script.sh <sitename>" exit 1
fi if [ -f "$1" ]; then echo "File exists"
elif [ -d "$1" ]; then echo "It is a directory"
else echo "Not found"
fi
#!/bin/bash
if [ -z "$1" ]; then echo "Error: No argument given" echo "Usage: ./script.sh <sitename>" exit 1
fi if [ -f "$1" ]; then echo "File exists"
elif [ -d "$1" ]; then echo "It is a directory"
else echo "Not found"
fi
#!/bin/bash
if [ -z "$1" ]; then echo "Error: No argument given" echo "Usage: ./script.sh <sitename>" exit 1
fi if [ -f "$1" ]; then echo "File exists"
elif [ -d "$1" ]; then echo "It is a directory"
else echo "Not found"
fi
#!/bin/bash
case $1 in ---weight: 500;">install) echo "Installing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y ;; ---weight: 500;">remove) echo "Removing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">remove nginx -y ;; ---weight: 500;">status) -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx ;; *) echo "Usage: ./script.sh ---weight: 500;">install | ---weight: 500;">remove | ---weight: 500;">status" exit 1 ;;
esac
#!/bin/bash
case $1 in ---weight: 500;">install) echo "Installing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y ;; ---weight: 500;">remove) echo "Removing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">remove nginx -y ;; ---weight: 500;">status) -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx ;; *) echo "Usage: ./script.sh ---weight: 500;">install | ---weight: 500;">remove | ---weight: 500;">status" exit 1 ;;
esac
#!/bin/bash
case $1 in ---weight: 500;">install) echo "Installing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y ;; ---weight: 500;">remove) echo "Removing..." -weight: 600;">sudo -weight: 500;">apt -weight: 500;">remove nginx -y ;; ---weight: 500;">status) -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status nginx ;; *) echo "Usage: ./script.sh ---weight: 500;">install | ---weight: 500;">remove | ---weight: 500;">status" exit 1 ;;
esac
#!/bin/bash
# Loop over numbers
for i in 1 2 3 4 5; do echo "Number: $i"
done # Loop over sites and create folders
for site in site1 site2 site3; do -weight: 600;">sudo mkdir -p /var/www/$site echo "<h1>Welcome to $site</h1>" | -weight: 600;">sudo tee /var/www/$site/index.html echo "Created $site"
done
#!/bin/bash
# Loop over numbers
for i in 1 2 3 4 5; do echo "Number: $i"
done # Loop over sites and create folders
for site in site1 site2 site3; do -weight: 600;">sudo mkdir -p /var/www/$site echo "<h1>Welcome to $site</h1>" | -weight: 600;">sudo tee /var/www/$site/index.html echo "Created $site"
done
#!/bin/bash
# Loop over numbers
for i in 1 2 3 4 5; do echo "Number: $i"
done # Loop over sites and create folders
for site in site1 site2 site3; do -weight: 600;">sudo mkdir -p /var/www/$site echo "<h1>Welcome to $site</h1>" | -weight: 600;">sudo tee /var/www/$site/index.html echo "Created $site"
done
# Normal folder (no -weight: 600;">sudo needed)
cat > index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF # Protected folder — use -weight: 600;">sudo tee
-weight: 600;">sudo tee /var/www/html/index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF
# Normal folder (no -weight: 600;">sudo needed)
cat > index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF # Protected folder — use -weight: 600;">sudo tee
-weight: 600;">sudo tee /var/www/html/index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF
# Normal folder (no -weight: 600;">sudo needed)
cat > index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF # Protected folder — use -weight: 600;">sudo tee
-weight: 600;">sudo tee /var/www/html/index.html << EOF
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF
echo "hello" > file.txt # write (overwrite)
echo "hello" >> file.txt # append
command | -weight: 600;">sudo tee file.txt # pipe to tee (for protected files)
./script.sh > output.log 2>&1 # redirect stdout AND stderr to file
echo "hello" > file.txt # write (overwrite)
echo "hello" >> file.txt # append
command | -weight: 600;">sudo tee file.txt # pipe to tee (for protected files)
./script.sh > output.log 2>&1 # redirect stdout AND stderr to file
echo "hello" > file.txt # write (overwrite)
echo "hello" >> file.txt # append
command | -weight: 600;">sudo tee file.txt # pipe to tee (for protected files)
./script.sh > output.log 2>&1 # redirect stdout AND stderr to file
#!/bin/bash
# deploy.sh — Clone from GitHub and host with Docker REPO=$1
PORT=${2:-8080} # default port 8080 if not given
NAME=${3:-mysite} # default name mysite if not given # Validate input
if [ -z "$REPO" ]; then echo "Usage: ./deploy.sh <github-repo-url> [port] [container-name]" exit 1
fi echo "==> Cloning repo..."
-weight: 500;">git clone $REPO site_files echo "==> Starting Docker container on port $PORT..."
-weight: 500;">docker run -d \ --name $NAME \ -p $PORT:80 \ -v $(pwd)/site_files:/usr/share/nginx/html \ nginx echo "==> Done! Visit http://localhost:$PORT"
-weight: 500;">docker ps | grep $NAME
#!/bin/bash
# deploy.sh — Clone from GitHub and host with Docker REPO=$1
PORT=${2:-8080} # default port 8080 if not given
NAME=${3:-mysite} # default name mysite if not given # Validate input
if [ -z "$REPO" ]; then echo "Usage: ./deploy.sh <github-repo-url> [port] [container-name]" exit 1
fi echo "==> Cloning repo..."
-weight: 500;">git clone $REPO site_files echo "==> Starting Docker container on port $PORT..."
-weight: 500;">docker run -d \ --name $NAME \ -p $PORT:80 \ -v $(pwd)/site_files:/usr/share/nginx/html \ nginx echo "==> Done! Visit http://localhost:$PORT"
-weight: 500;">docker ps | grep $NAME
#!/bin/bash
# deploy.sh — Clone from GitHub and host with Docker REPO=$1
PORT=${2:-8080} # default port 8080 if not given
NAME=${3:-mysite} # default name mysite if not given # Validate input
if [ -z "$REPO" ]; then echo "Usage: ./deploy.sh <github-repo-url> [port] [container-name]" exit 1
fi echo "==> Cloning repo..."
-weight: 500;">git clone $REPO site_files echo "==> Starting Docker container on port $PORT..."
-weight: 500;">docker run -d \ --name $NAME \ -p $PORT:80 \ -v $(pwd)/site_files:/usr/share/nginx/html \ nginx echo "==> Done! Visit http://localhost:$PORT"
-weight: 500;">docker ps | grep $NAME
chmod +x deploy.sh
./deploy.sh https://github.com/user/mysite.-weight: 500;">git 8081 coolsite
chmod +x deploy.sh
./deploy.sh https://github.com/user/mysite.-weight: 500;">git 8081 coolsite
chmod +x deploy.sh
./deploy.sh https://github.com/user/mysite.-weight: 500;">git 8081 coolsite
#!/bin/bash
# setup_vhost.sh — Create Apache virtual host SITE=$1 if [ -z "$SITE" ]; then echo "Usage: ./setup_vhost.sh <sitename>" exit 1
fi echo "==> Creating directory..."
-weight: 600;">sudo mkdir -p /var/www/$SITE echo "==> Creating HTML page..."
-weight: 600;">sudo tee /var/www/$SITE/index.html << EOF
<html>
<body>
<h1>Welcome to $SITE</h1>
</body>
</html>
EOF echo "==> Setting permissions..."
-weight: 600;">sudo chown -R www-data:www-data /var/www/$SITE
-weight: 600;">sudo chmod -R 755 /var/www/$SITE echo "==> Creating Virtual Host config..."
-weight: 600;">sudo tee /etc/apache2/sites-available/$SITE.conf << EOF
<VirtualHost *:80> ServerName $SITE.local DocumentRoot /var/www/$SITE ErrorLog \${APACHE_LOG_DIR}/${SITE}_error.log CustomLog \${APACHE_LOG_DIR}/${SITE}_access.log combined
</VirtualHost>
EOF echo "==> Enabling site..."
-weight: 600;">sudo a2ensite $SITE.conf
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 echo "==> Adding to /etc/hosts..."
echo "127.0.0.1 $SITE.local" | -weight: 600;">sudo tee -a /etc/hosts echo "==> Done! Visit http://$SITE.local"
#!/bin/bash
# setup_vhost.sh — Create Apache virtual host SITE=$1 if [ -z "$SITE" ]; then echo "Usage: ./setup_vhost.sh <sitename>" exit 1
fi echo "==> Creating directory..."
-weight: 600;">sudo mkdir -p /var/www/$SITE echo "==> Creating HTML page..."
-weight: 600;">sudo tee /var/www/$SITE/index.html << EOF
<html>
<body>
<h1>Welcome to $SITE</h1>
</body>
</html>
EOF echo "==> Setting permissions..."
-weight: 600;">sudo chown -R www-data:www-data /var/www/$SITE
-weight: 600;">sudo chmod -R 755 /var/www/$SITE echo "==> Creating Virtual Host config..."
-weight: 600;">sudo tee /etc/apache2/sites-available/$SITE.conf << EOF
<VirtualHost *:80> ServerName $SITE.local DocumentRoot /var/www/$SITE ErrorLog \${APACHE_LOG_DIR}/${SITE}_error.log CustomLog \${APACHE_LOG_DIR}/${SITE}_access.log combined
</VirtualHost>
EOF echo "==> Enabling site..."
-weight: 600;">sudo a2ensite $SITE.conf
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 echo "==> Adding to /etc/hosts..."
echo "127.0.0.1 $SITE.local" | -weight: 600;">sudo tee -a /etc/hosts echo "==> Done! Visit http://$SITE.local"
#!/bin/bash
# setup_vhost.sh — Create Apache virtual host SITE=$1 if [ -z "$SITE" ]; then echo "Usage: ./setup_vhost.sh <sitename>" exit 1
fi echo "==> Creating directory..."
-weight: 600;">sudo mkdir -p /var/www/$SITE echo "==> Creating HTML page..."
-weight: 600;">sudo tee /var/www/$SITE/index.html << EOF
<html>
<body>
<h1>Welcome to $SITE</h1>
</body>
</html>
EOF echo "==> Setting permissions..."
-weight: 600;">sudo chown -R www-data:www-data /var/www/$SITE
-weight: 600;">sudo chmod -R 755 /var/www/$SITE echo "==> Creating Virtual Host config..."
-weight: 600;">sudo tee /etc/apache2/sites-available/$SITE.conf << EOF
<VirtualHost *:80> ServerName $SITE.local DocumentRoot /var/www/$SITE ErrorLog \${APACHE_LOG_DIR}/${SITE}_error.log CustomLog \${APACHE_LOG_DIR}/${SITE}_access.log combined
</VirtualHost>
EOF echo "==> Enabling site..."
-weight: 600;">sudo a2ensite $SITE.conf
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 echo "==> Adding to /etc/hosts..."
echo "127.0.0.1 $SITE.local" | -weight: 600;">sudo tee -a /etc/hosts echo "==> Done! Visit http://$SITE.local"
-weight: 500;">docker pull nginx # download image
-weight: 500;">docker pull ubuntu:22.04 # specific version/tag
-weight: 500;">docker images # list all downloaded images
-weight: 500;">docker rmi nginx # -weight: 500;">remove image
-weight: 500;">docker pull nginx # download image
-weight: 500;">docker pull ubuntu:22.04 # specific version/tag
-weight: 500;">docker images # list all downloaded images
-weight: 500;">docker rmi nginx # -weight: 500;">remove image
-weight: 500;">docker pull nginx # download image
-weight: 500;">docker pull ubuntu:22.04 # specific version/tag
-weight: 500;">docker images # list all downloaded images
-weight: 500;">docker rmi nginx # -weight: 500;">remove image
-weight: 500;">docker run nginx # basic run
-weight: 500;">docker run -d nginx # detached (background)
-weight: 500;">docker run -it ubuntu bash # interactive shell
-weight: 500;">docker run --name mysite nginx # with custom name
-weight: 500;">docker run -p 8080:80 nginx # port mapping HOST:CONTAINER
-weight: 500;">docker run -d -p 8080:80 --name s nginx # all combined
-weight: 500;">docker run --rm nginx # auto--weight: 500;">remove when stopped
-weight: 500;">docker run nginx # basic run
-weight: 500;">docker run -d nginx # detached (background)
-weight: 500;">docker run -it ubuntu bash # interactive shell
-weight: 500;">docker run --name mysite nginx # with custom name
-weight: 500;">docker run -p 8080:80 nginx # port mapping HOST:CONTAINER
-weight: 500;">docker run -d -p 8080:80 --name s nginx # all combined
-weight: 500;">docker run --rm nginx # auto--weight: 500;">remove when stopped
-weight: 500;">docker run nginx # basic run
-weight: 500;">docker run -d nginx # detached (background)
-weight: 500;">docker run -it ubuntu bash # interactive shell
-weight: 500;">docker run --name mysite nginx # with custom name
-weight: 500;">docker run -p 8080:80 nginx # port mapping HOST:CONTAINER
-weight: 500;">docker run -d -p 8080:80 --name s nginx # all combined
-weight: 500;">docker run --rm nginx # auto--weight: 500;">remove when stopped
# Mount a single file
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx # Mount entire folder
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/mysite:/usr/share/nginx/html \ nginx
# Mount a single file
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx # Mount entire folder
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/mysite:/usr/share/nginx/html \ nginx
# Mount a single file
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/index.html:/usr/share/nginx/html/index.html \ nginx # Mount entire folder
-weight: 500;">docker run -d -p 8080:80 \ -v $(pwd)/mysite:/usr/share/nginx/html \ nginx
-weight: 500;">docker ps # running containers
-weight: 500;">docker ps -a # all containers (including stopped)
-weight: 500;">docker -weight: 500;">stop mysite # -weight: 500;">stop container
-weight: 500;">docker -weight: 500;">start mysite # -weight: 500;">start stopped container
-weight: 500;">docker rm mysite # -weight: 500;">remove container
-weight: 500;">docker logs mysite # view logs
-weight: 500;">docker inspect mysite # detailed info
-weight: 500;">docker ps # running containers
-weight: 500;">docker ps -a # all containers (including stopped)
-weight: 500;">docker -weight: 500;">stop mysite # -weight: 500;">stop container
-weight: 500;">docker -weight: 500;">start mysite # -weight: 500;">start stopped container
-weight: 500;">docker rm mysite # -weight: 500;">remove container
-weight: 500;">docker logs mysite # view logs
-weight: 500;">docker inspect mysite # detailed info
-weight: 500;">docker ps # running containers
-weight: 500;">docker ps -a # all containers (including stopped)
-weight: 500;">docker -weight: 500;">stop mysite # -weight: 500;">stop container
-weight: 500;">docker -weight: 500;">start mysite # -weight: 500;">start stopped container
-weight: 500;">docker rm mysite # -weight: 500;">remove container
-weight: 500;">docker logs mysite # view logs
-weight: 500;">docker inspect mysite # detailed info
-weight: 500;">docker exec -it mysite bash # open NEW shell (safe — exit won't -weight: 500;">stop container)
-weight: 500;">docker attach mysite # attach to main process (exit WILL -weight: 500;">stop container) # safe detach: CTRL+P+Q
-weight: 500;">docker exec -it mysite bash # open NEW shell (safe — exit won't -weight: 500;">stop container)
-weight: 500;">docker attach mysite # attach to main process (exit WILL -weight: 500;">stop container) # safe detach: CTRL+P+Q
-weight: 500;">docker exec -it mysite bash # open NEW shell (safe — exit won't -weight: 500;">stop container)
-weight: 500;">docker attach mysite # attach to main process (exit WILL -weight: 500;">stop container) # safe detach: CTRL+P+Q
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) # -weight: 500;">stop ALL running containers
-weight: 500;">docker rm $(-weight: 500;">docker ps -aq) # -weight: 500;">remove ALL containers
-weight: 500;">docker rmi $(-weight: 500;">docker images -q) # -weight: 500;">remove ALL images
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) # -weight: 500;">stop ALL running containers
-weight: 500;">docker rm $(-weight: 500;">docker ps -aq) # -weight: 500;">remove ALL containers
-weight: 500;">docker rmi $(-weight: 500;">docker images -q) # -weight: 500;">remove ALL images
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) # -weight: 500;">stop ALL running containers
-weight: 500;">docker rm $(-weight: 500;">docker ps -aq) # -weight: 500;">remove ALL containers
-weight: 500;">docker rmi $(-weight: 500;">docker images -q) # -weight: 500;">remove ALL images
755 # directories → owner:rwx group:r-x others:r-x
644 # files → owner:rw- group:r-- others:r--
600 # private keys → owner:rw- group:--- others:---
777 # ❌ NEVER USE — anyone can write/execute = security risk
755 # directories → owner:rwx group:r-x others:r-x
644 # files → owner:rw- group:r-- others:r--
600 # private keys → owner:rw- group:--- others:---
777 # ❌ NEVER USE — anyone can write/execute = security risk
755 # directories → owner:rwx group:r-x others:r-x
644 # files → owner:rw- group:r-- others:r--
600 # private keys → owner:rw- group:--- others:---
777 # ❌ NEVER USE — anyone can write/execute = security risk
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ # fix ownership
-weight: 600;">sudo chmod -R 755 /var/www/html/ # fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ # fix ownership
-weight: 600;">sudo chmod -R 755 /var/www/html/ # fix permissions
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ # fix ownership
-weight: 600;">sudo chmod -R 755 /var/www/html/ # fix permissions
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 # -weight: 500;">start now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # -weight: 500;">stop now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 # -weight: 500;">stop + -weight: 500;">start (brief downtime)
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 # apply config changes gracefully (no downtime)
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 # -weight: 500;">start now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # -weight: 500;">stop now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 # -weight: 500;">stop + -weight: 500;">start (brief downtime)
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 # apply config changes gracefully (no downtime)
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 # -weight: 500;">start now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 # -weight: 500;">stop now
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 # -weight: 500;">stop + -weight: 500;">start (brief downtime)
-weight: 600;">sudo -weight: 500;">systemctl reload apache2 # apply config changes gracefully (no downtime)
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 # auto--weight: 500;">start on reboot
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 # check if running
# WRONG ❌ — >> is for files, not commands
echo "hello" >> -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — use pipe | before -weight: 600;">sudo tee
echo "hello" | -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — append mode with -weight: 600;">sudo tee -a
echo "hello" | -weight: 600;">sudo tee -a /var/www/html/index.html
# WRONG ❌ — >> is for files, not commands
echo "hello" >> -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — use pipe | before -weight: 600;">sudo tee
echo "hello" | -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — append mode with -weight: 600;">sudo tee -a
echo "hello" | -weight: 600;">sudo tee -a /var/www/html/index.html
# WRONG ❌ — >> is for files, not commands
echo "hello" >> -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — use pipe | before -weight: 600;">sudo tee
echo "hello" | -weight: 600;">sudo tee /var/www/html/index.html # CORRECT ✅ — append mode with -weight: 600;">sudo tee -a
echo "hello" | -weight: 600;">sudo tee -a /var/www/html/index.html
# attach — connects to main process
# ⚠️ typing "exit" STOPS the container
-weight: 500;">docker attach mycontainer
# Safe way to leave: CTRL+P+Q # exec — opens a NEW shell
# ✅ typing "exit" is completely safe, container keeps running
-weight: 500;">docker exec -it mycontainer bash
# attach — connects to main process
# ⚠️ typing "exit" STOPS the container
-weight: 500;">docker attach mycontainer
# Safe way to leave: CTRL+P+Q # exec — opens a NEW shell
# ✅ typing "exit" is completely safe, container keeps running
-weight: 500;">docker exec -it mycontainer bash
# attach — connects to main process
# ⚠️ typing "exit" STOPS the container
-weight: 500;">docker attach mycontainer
# Safe way to leave: CTRL+P+Q # exec — opens a NEW shell
# ✅ typing "exit" is completely safe, container keeps running
-weight: 500;">docker exec -it mycontainer bash
GitHub Repo → -weight: 500;">git clone → Docker container → Live website
GitHub Repo → -weight: 500;">git clone → Docker container → Live website
GitHub Repo → -weight: 500;">git clone → Docker container → Live website
-weight: 500;">git clone https://github.com/user/repo.-weight: 500;">git
cd repo
-weight: 500;">docker run -d -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx
-weight: 500;">git clone https://github.com/user/repo.-weight: 500;">git
cd repo
-weight: 500;">docker run -d -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx
-weight: 500;">git clone https://github.com/user/repo.-weight: 500;">git
cd repo
-weight: 500;">docker run -d -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx
# Apache — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2
echo "<h1>Hello</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ && -weight: 600;">sudo chmod -R 755 /var/www/html/ # Nginx — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx # Docker — nginx with your file
-weight: 500;">docker run -d -p 8080:80 -v $(pwd)/index.html:/usr/share/nginx/html/index.html nginx # Docker — clone from github and host
-weight: 500;">git clone <repo-url> site && -weight: 500;">docker run -d -p 8080:80 -v $(pwd)/site:/usr/share/nginx/html nginx # Docker — cleanup everything
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) && -weight: 500;">docker rm $(-weight: 500;">docker ps -aq)
# Apache — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2
echo "<h1>Hello</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ && -weight: 600;">sudo chmod -R 755 /var/www/html/ # Nginx — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx # Docker — nginx with your file
-weight: 500;">docker run -d -p 8080:80 -v $(pwd)/index.html:/usr/share/nginx/html/index.html nginx # Docker — clone from github and host
-weight: 500;">git clone <repo-url> site && -weight: 500;">docker run -d -p 8080:80 -v $(pwd)/site:/usr/share/nginx/html nginx # Docker — cleanup everything
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) && -weight: 500;">docker rm $(-weight: 500;">docker ps -aq)
# Apache — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2
echo "<h1>Hello</h1>" | -weight: 600;">sudo tee /var/www/html/index.html
-weight: 600;">sudo chown -R www-data:www-data /var/www/html/ && -weight: 600;">sudo chmod -R 755 /var/www/html/ # Nginx — -weight: 500;">install, -weight: 500;">start, deploy
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx && -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx # Docker — nginx with your file
-weight: 500;">docker run -d -p 8080:80 -v $(pwd)/index.html:/usr/share/nginx/html/index.html nginx # Docker — clone from github and host
-weight: 500;">git clone <repo-url> site && -weight: 500;">docker run -d -p 8080:80 -v $(pwd)/site:/usr/share/nginx/html nginx # Docker — cleanup everything
-weight: 500;">docker -weight: 500;">stop $(-weight: 500;">docker ps -q) && -weight: 500;">docker rm $(-weight: 500;">docker ps -aq) - Hosting Apache2 — Traditional Way
- Hosting Nginx — Traditional Way
- Multiple Static Sites — Virtual Hosts & Server Blocks
- Hosting via Docker
- Clone from GitHub & Host via Docker
- Bash Scripting — Automate Everything
- Docker Cheatsheet
- Key Concepts & Golden Rules