Linux Server Setup and Cloud Integration for Web Hosting
Project Overview:
The goal of this project is to set up a web hosting environment on an Ubuntu/CentOS Linux server, with Apache and Nginx serving dynamic content using PHP and MySQL. The project integrates AWS cloud services for high availability, automated backups, and disaster recovery. Additionally, you will handle L2 escalations, documenting the issues and resolutions.
Phase 1: Setting Up the Linux Server (Ubuntu/CentOS)
Launch an EC2 Instance on AWS:
AWS EC2: Launch a new Ubuntu or CentOS instance using the AWS Management Console.
Instance Type: Choose an appropriate instance type (e.g., t2.micro or t3.medium depending on your resource needs).
Key Pair: Create a key pair to securely connect to the instance using SSH.
Connect to Your Instance:
- Use an SSH client to connect to your EC2 instance:
ssh -i /path/to/your-key.pem ubuntu@<public-ip>
System Updates and Performance Tuning:
Update all installed packages:
sudo apt update && sudo apt upgrade -y # For Ubuntu sudo yum update -y # For CentOS
Optimize kernel parameters for performance (e.g., setting swappiness, adjusting file descriptors):
sudo sysctl -w vm.swappiness=10 sudo sysctl -w fs.file-max=2097152
Install performance monitoring tools like
htop
,iostat
, andvnstat
to monitor CPU, disk I/O, and network performance.
Phase 2: Web Server and Database Setup
Install Apache & Nginx:
Install Apache to serve static content:
sudo apt install apache2 -y # For Ubuntu sudo yum install httpd -y # For CentOS
Install Nginx to act as a reverse proxy and load balancer:
sudo apt install nginx -y # For Ubuntu sudo yum install nginx -y # For CentOS
Install PHP and MySQL:
Install PHP and the necessary modules to run PHP applications:
sudo apt install php php-fpm php-mysql -y # For Ubuntu sudo yum install php php-fpm php-mysql -y # For CentOS
Install MySQL for database management:
sudo apt install mysql-server -y # For Ubuntu sudo yum install mysql-server -y # For CentOS
Secure the MySQL installation:
sudo mysql_secure_installation
Create a new database and user for your web application:
CREATE DATABASE webapp_db; CREATE USER 'webapp_user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON webapp_db.* TO 'webapp_user'@'localhost'; FLUSH PRIVILEGES;
Configure Apache/Nginx and PHP:
Set up Apache to serve web pages and integrate with PHP for dynamic content:
sudo nano /etc/apache2/sites-available/000-default.conf # Ubuntu sudo nano /etc/httpd/conf/httpd.conf # CentOS
For Nginx, configure as a reverse proxy and load balancer:
sudo nano /etc/nginx/sites-available/default # Ubuntu sudo nano /etc/nginx/nginx.conf # CentOS
Test the configuration and restart services:
bashCopy codesudo systemctl restart apache2 nginx
Install FTP Server:
To enable secure file transfers, install and configure an FTP server like vsftpd:
bashCopy codesudo apt install vsftpd -y sudo nano /etc/vsftpd.conf
Phase 3: Security Setup
Install and Configure Anti-Virus:
Install ClamAV to scan for malware:
sudo apt install clamav clamav-daemon -y
Configure a cron job for daily scans.
Set Up Web Application Firewall (WAF):
Use ModSecurity for Apache or NAXSI for Nginx to protect against common web attacks:
sudo apt install libapache2-mod-security2 -y sudo systemctl restart apache2
Configure SSL for HTTPS:
Install SSL certificates using Let's Encrypt:
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx
Phase 4: Backup & Disaster Recovery
Deploy Backup Agents:
Set up AWS S3 for automated backups:
aws s3 cp /var/www/html s3://<your-bucket>/backup --recursive
Configure cron jobs for regular MySQL and web file backups.
Disaster Recovery Plan:
Automate recovery procedures by creating shell scripts that restore backups from S3.
Test disaster recovery by simulating server failures and validating recovery processes.
Phase 5: Handling L2 Escalations and Support
Simulate Server Issues:
Create scenarios like server crashes or database errors (e.g., stopping the Apache or MySQL services):
sudo systemctl stop apache2 mysql
Troubleshoot and document the issues (e.g., analyzing logs from
/var/log/apache2
and/var/log/mysql
).
Document Escalation Procedures:
- Write operational procedures for handling L2 escalations, including providing logs, diagnostics, and solutions to support teams.
Support Over Email and Help Desk:
- Simulate providing support to "customers" via email, offering detailed logs and troubleshooting steps.
Phase 6: Cloud Integration with AWS
Auto Scaling and Load Balancing:
Set up Auto Scaling on AWS to dynamically add/remove EC2 instances based on traffic load.
Use Elastic Load Balancer (ELB) to distribute traffic evenly across your Nginx/Apache servers.
AWS Monitoring and Alerts:
- Enable CloudWatch monitoring for the EC2 instance and set up Alarms to notify on high CPU usage, storage issues, etc.
Disaster Recovery:
- Automate EC2 instance snapshots and integrate S3 for storage redundancy.
Expected Outcomes:
By the end of this project, you will have:
A fully configured web hosting environment on a Linux server.
A secure setup with antivirus, firewalls, and SSL.
Regular backups in AWS S3 and a tested disaster recovery plan.
Handling of L2 escalations, simulating customer support scenarios and documentation.
This project will highlight your proficiency in Linux server management, cloud integration (AWS), web hosting, security, and handling escalations—perfectly matching the job description for the Linux server administrator role.
Subscribe to my newsletter
Read articles from Irfan Mestri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Irfan Mestri
Irfan Mestri
Aspiring DevOps Engineer | Passionate about Cloud & Automation 🌩️ | Learning AWS, Linux, and DevOps Tools ⚙️ I'm diving into the world of DevOps, starting with the basics of AWS, Linux, and essential DevOps tools. With a growing passion for cloud technologies and automation, I’m excited to build scalable, secure, and efficient solutions. Follow along as I document my learning journey, share insights, and tackle real-world projects!