How to Install Ubuntu Server and Configure a Web Server (Step by Step)
Published: December 19, 2024
In this guide, you will learn how to install Ubuntu Server, configure Apache, and set up your first HTML website.
1. Prepare Your System
• Create Bootable USB
- Download the Ubuntu Server ISO from the official website.
- Create a bootable USB using Rufus (Windows) or Etcher (Linux/macOS).
- Boot from the USB and follow the installation prompts to install Ubuntu Server.
- During installation, configure a hostname (e.g.,
myserver
) and create a user account.
• Update and Upgrade the System
- After installation, log in to your server and run:
sudo apt update && sudo apt upgrade -y
2. Install & Configure Apache2 Web Server
• Installation Process
- To install Apache, run:
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
• Configure Firewall for Apache
- If UFW (Uncomplicated Firewall) is active, allow HTTP and HTTPS traffic:
sudo ufw allow 'Apache Full'
sudo ufw enable
• Set Up Your First HTML Website
- Create a New Directory for Your Website:
sudo mkdir -p /var/www/{{your_website_name}}
sudo chown -R $USER:$USER /var/www/{{your_website_name}}
echo "<!DOCTYPE html>
<html>
<head>
<title>Welcome to My Website</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first website hosted on Apache.</p>
</body>
</html>" | sudo tee /var/www/{{your_website_name}}/index.html
• Create an Apache Configuration File
- Create a new configuration file for your website:
sudo nano /etc/apache2/sites-available/{{your_website_name}}.conf
<VirtualHost *:80>
ServerName {{your_website_name for eg. aeolink.com or ommnium.com}}
DocumentRoot /var/www/{{your_website_name}}
<Directory /var/www/{{your_website_name}}>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite mywebsite.conf
sudo systemctl reload apache2
3. Update Your Hosts File
• (Optional for Local Testing)
- If you are testing locally, add this line to your
/etc/hosts
file on your computer:
127.0.0.1 mywebsite.local
4. Final Step
• Test Your Website
- Visit
http://mywebsite.local
(or your server's IP address if testing remotely) in a browser. You should see your "Hello, World!" page.
• Conclusion
- Congratulations! You have successfully installed Ubuntu Server, configured Apache, and deployed your first HTML website. From here, you can add more content or explore dynamic websites using PHP and MySQL.