Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding

Products

  1. Home
  2. Developers
  3. How to Set Up a Basic Web Server on Ubuntu

How to Set Up a Basic Web Server on Ubuntu

  • By Gcore
  • December 6, 2023
  • 3 min read
How to Set Up a Basic Web Server on Ubuntu

This guide offers a straightforward approach to setting up a basic web server on Ubuntu. Targeted at beginners and intermediate users, it outlines the key steps for installing, configuring, and maintaining a web server on this user-friendly Linux-based operating system. This article is an essential resource for anyone interested in hosting websites or applications using Ubuntu.

What Is a Web Server on Ubuntu

A web server is a software system that delivers web pages, images, and other content to users over the internet or an intranet. It responds to requests from clients, usually web browsers, using the Hypertext Transfer Protocol (HTTP). Ubuntu is a popular Linux distribution that is widely used for hosting web servers because it is stable, secure, and user-friendly. Web servers on Ubuntu can range from serving simple static websites to hosting complex web applications. Here it’s key features:

  1. Variety of Web Server Software Options. Ubuntu supports various web server software like Apache, Nginx, and Lighttpd, each with unique features such as Apache’s modularity and Nginx’s efficient handling of static content and heavy traffic.
  2. Ease of Installation and Configuration. Ubuntu’s APT system simplifies the installation and updating of web server software, offering tested and stable versions in its repositories. Well-documented and organized configuration files further ease the setup process.
  3. Strong Security Features. Ubuntu includes essential security features like AppArmor and regular updates, supported by a security-focused community, ensuring a secure web server environment.
  4. Compatibility with Common Web Technologies. Seamless integration with essential web technologies and databases such as PHP, Python, Ruby, MySQL, and PostgreSQL is a hallmark of these servers, making them ideal for a variety of web applications.
  5. Community and Documentation Support. Ubuntu’s dynamic community provides extensive learning and troubleshooting resources, including detailed documentation, tutorials, and forums, aiding users of all levels in web server setup and maintenance.

In the following section, we will discuss the process of setting it up on Ubuntu.

Process for Setting Up a Basic Web Server on Ubuntu

To set up a basic web server on Ubuntu, follow the step-by-step instructions provided below.

  1. Updating the System. Begin by updating your Ubuntu system to ensure all packages are current. The system will fetch the list of available updates and then apply them.
sudo apt update && sudo apt upgrade
  1. Installing the Web Server Software (Apache). Install Apache, a popular web server software.
sudo apt install apache2

Sample Output:

  1. Adjusting the Firewall. Modify the firewall settings to allow web traffic. Firewall rules will be updated to allow access to Apache by using this command.
sudo ufw allow 'Apache Full'
  1. Checking Apache Installation. Verify that Apache was successfully installed and is running. A status message indicating that Apache is active and running should show up by using this command below.
sudo systemctl status apache2

Sample Output:

  1. Creating a Test Web Page. Create a simple HTML file to test the Apache server.
echo "<html><body><h1>Hello, Ubuntu Server!</h1></body></html>" | sudo tee /var/www/html/test.html

A new HTML file named ‘test.html’ will be created in the web root directory.

  1. Accessing the Test Page. Access the test page via a web browser. When you navigate to http://your_server_IP/test.html, you should see the message “Hello, Ubuntu Server!” displayed in your browser, confirming that Apache is serving web pages correctly.
  2. Setting Up Virtual Hosts (Optional). If you plan to host multiple sites, set up virtual hosts. Instructions will vary based on the domain and content. Separate directories for each website, allowing for individual site hosting.
  3. Securing Your Web Server (Optional). Implement SSL/TLS for secure data transmission. This involves acquiring a certificate (e.g., Let’s Encrypt) and configuring Apache. An encrypted connection established between your server and its visitors.

Congratulations! By following these steps, you now have a basic yet fully functional web server running on Ubuntu, ready to host websites and web applications. This process can be customized and expanded based on your specific hosting needs and more advanced configurations.

Conclusion

Want to run Ubuntu in a virtual environment? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Ubuntu:

Choose an instance

Related articles

What Is a High Availability Server?

Every minute your servers are down, your business is bleeding. For e-commerce sites, healthcare platforms, and revenue-critical applications, an outage isn't just an inconvenience. It's a direct hit to your bottom line, your reputation, and

Cloud vs Dedicated Server: Which Is Right for You?

Your server choice could be quietly costing you, or quietly holding you back. Pick the wrong infrastructure for your workload and you're either overpaying for idle hardware every month or watching your site buckle under traffic spikes you c

VPS vs Dedicated Server
VPS vs Dedicated Server: Which One Do You Need?

Your site is humming along fine, until it isn't. Traffic spikes, page loads crawl, and your hosting plan buckles under pressure right when it matters most. Choosing between a VPS and a dedicated server isn't just a technical checkbox. It's

Multi-Cloud Plan: What It Is and How It Works

Your cloud provider goes down. Applications fail. Customers can't access your services. And because you've built everything around a single vendor, there's nothing you can do but wait. For organizations locked into one cloud platform, this

Vendor Lock-In in Cloud Computing: What It Is and How to Avoid It

Imagine discovering that migrating your company's data to a new cloud provider will cost hundreds of thousands of dollars in egress fees alone, before you've even touched the re-engineering work. Or worse, picture being in Synapse Financial

What Is Sovereign Cloud and Why Does It Matter?

Picture this: a foreign government issues a legal order forcing your cloud provider to hand over sensitive patient records, classified research data, or critical national infrastructure details. You can't stop it. This isn't hypothetical. G

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.