Virtualization and Web Hosting: A Hands-on Learning Experience
Embarking on the journey of learning virtualization was both exciting and challenging. My primary goal was to understand virtual machines, and I chose to use Vagrant on VMware Fusion as my platform. However, this path was not without its hurdles.
One of the first challenges I faced was related to computer architecture. Using a Laptop with an Apple Silicon CPU presented limitations, particularly in the availability of Linux distributions on Vagrant Cloud. This required me to adapt and find compatible distributions that could run smoothly on my setup.
Despite these challenges, the experience was incredibly rewarding. Working with virtual machines allowed me to deepen my understanding of Linux commands and system operations. Each virtual environment I set up became a sandbox for experimentation and learning, providing me with practical insights into the workings of Linux systems.
Here are some of the key commands that became essential tools in my daily workflow:
File System Navigation and Management
ls: This command helped me list files and directories, with useful flags like
-la
for detailed views and hidden filescd: Navigation between directories became second nature, using both absolute and relative paths
pwd: Crucial for displaying the current working directory, ensuring precise location awareness
cp and mv: Essential for file operations, with various flags for recursive operations and preserving attributes
rm and mkdir: File and directory management, learning to use them safely with flags like
-rf
for recursive removalfind: Powerful tool for locating files and executing operations on them
System Administration and Security
chmod and chown: Critical for managing file permissions and ownership, understanding octal notation
ps and top: Monitoring processes and system resources in real-time
df and du: Tracking disk usage and available space
systemctl: Managing system services and their states
Web Server Provisioning and Automation
My virtualization journey expanded into web server provisioning, where I focused on setting up Apache on Ubuntu distributions. Starting with basic Apache installation and configuration, I learned essential commands for service management and virtual hosting. The learning curve intensified when I implemented WordPress, which required setting up a complete LAMP stack - Linux, Apache, MySQL, and PHP. This involved installing necessary packages, configuring databases, and managing proper file permissions for WordPress operations.
To make this process more efficient, I embraced automation using Vagrant's provisioning capabilities. By creating scripts that automated the entire setup process, from installing Apache to configuring WordPress, I could spin up consistent development environments with a single command. This automation not only streamlined my workflow but also deepened my understanding of system administration, web server configuration, and Infrastructure as Code principles. The safe environment provided by virtual machines allowed me to experiment freely and learn from my mistakes, making each iteration a valuable learning experience.
Automation with Vagrant Provisioning
To streamline the process, I learned to automate these setups using Vagrant's provisioning capabilities:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
sudo apt update
sudo apt install apache2 \
ghostscript \
libapache2-mod-php \
mysql-server \
php \
php-bcmath \
php-curl \
php-imagick \
php-intl \
php-json \
php-mbstring \
php-mysql \
php-xml \
php-zip -y
sudo mkdir -p /srv/www
sudo chown www-data: /srv/www
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www
cat > /etc/apache2/sites-available/wordpress.conf <<EOF
<VirtualHost *:80>
DocumentRoot /srv/www/wordpress
<Directory /srv/www/wordpress>
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
Require all granted
</Directory>
<Directory /srv/www/wordpress/wp-content>
Options FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
EOF
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo a2dissite 000-default
mysql -u root -e 'CREATE DATABASE wordpress;'
mysql -u root -e 'CREATE USER wordpress@localhost IDENTIFIED BY "admin123";'
mysql -u root -e 'GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;'
mysql -u root -e 'FLUSH PRIVILEGES;'
sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php
sudo -u www-data sed -i 's/database_name_here/wordpress/' /srv/www/wordpress/wp-config.php
sudo -u www-data sed -i 's/username_here/wordpress/' /srv/www/wordpress/wp-config.php
sudo -u www-data sed -i 's/password_here/admin123/' /srv/www/wordpress/wp-config.php
systemctl restart mysql
systemctl restart apache2
SHELL
end
Learning Outcomes
Through this comprehensive journey, I gained practical experience in:
Linux system administration
Web server configuration and management
Database administration
Security best practices
Automation and Infrastructure as Code
The combination of virtualization technology and web server provisioning created a powerful learning environment where mistakes were safe to make and easy to fix. Each failed attempt at configuration or automation became a valuable lesson, contributing to a deeper understanding of both virtualization and web server management.
Looking Forward
As I continue this journey, I'm excited to explore more advanced topics, such as:
Container orchestration
Load balancing
Conclusion
Through this journey, I not only gained technical skills but also developed problem-solving abilities as I navigated the complexities of virtualization on a Mac Silicon CPU. This experience has been invaluable in my growth as a tech enthusiast and has laid a strong foundation for further exploration in the world of virtualization.
Cover image credit: prabhavenkat@slideserve
Subscribe to my newsletter
Read articles from Teslim Ibisomi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by