Welcome to the #90DaysOfDevOps Series! In this blog, we'll set up our very own web server on an Amazon EC2 instance. This project utilizes the popular Apache web server on an Ubuntu EC2 instance, providing you with hands-on experience with operating system basics, server configuration, and basic web administration.
Prerequisites:
Downloaded your EC2 private key (.pem file)
Public DNS name of your EC2 instance
SSH client installed (e.g., PuTTY for Windows)
Basic understanding of the Linux command line
1. Connecting to your EC2 instance:
Follow the steps outlined in the previous blog to connect to your EC2 instance using your SSH client and private key.
2. Installing Apache:
Update the package list:
sudo apt-get update
Install Apache:
sudo apt-get install apache2
Verify the installation by opening your browser and navigating to your EC2 instance's public IP address (e.g., http://<public_ip>). You should see the default Apache welcome page.
3. Configuring Apache:
Edit the Apache virtual host configuration file:
sudo nano /etc/apache2/sites-available/000-default.conf
Locate the <VirtualHost *:80> section and modify the document root directory:
DocumentRoot /var/www/html
Save the file and restart Apache:
sudo service apache2 restart
4. Creating your first web page:
Create a new directory to serve your web content:
sudo mkdir /var/www/html/mywebsite
Change ownership of the directory to the Apache user:
sudo chown -R www-data:www-data /var/www/html/mywebsite
Create a simple HTML file (e.g., index.html) within the directory:
<!DOCTYPE html>
<html>
<body>
<h1>Welcome to my first web server!</h1>
</body>
</html>
Restart Apache for the changes to take effect:
sudo service apache2 restart
In your browser, navigate to http://<public_ip>/mywebsite. You should see your newly created webpage.
5. Basic Web Administration:
Adding virtual hosts: Configure additional websites with different domain names on your server.
Securing your server: Implement security measures like firewalls and user authentication.
Installing additional software: Expand your server's functionality with tools like PHP and MySQL.
Congratulations! You've successfully set up a basic web server using Apache on your AWS EC2 instance. This blog has provided a foundational understanding of setting up a basic web server on an EC2 instance. Remember, this is just the beginning of your journey into the world of web hosting. Continue exploring, experiment, and expand your knowledge to build and manage robust web servers for your specific needs.
Thank you for reading!
*** Explore | Share | Grow ***
Comments