Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding
  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's the difference between multi-cloud and hybrid cloud?

Multi-cloud and hybrid cloud represent two distinct approaches to distributed computing architecture that build upon the foundation of cloud computing to help organizations improve their IT infrastructure.Multi-cloud environments involve us

What is multi-cloud? Strategy, benefits, and best practices

Multi-cloud is a cloud usage model where an organization utilizes public cloud services from two or more cloud service providers, often combining public, private, and hybrid clouds, as well as different service models, such as Infrastructur

What is cloud migration? Benefits, strategy, and best practices

Cloud migration is the process of transferring digital assets, such as data, applications, and IT resources, from on-premises data centers to cloud platforms, including public, private, hybrid, or multi-cloud environments. Organizations can

What is a private cloud? Benefits, use cases, and implementation

A private cloud is a cloud computing environment dedicated exclusively to a single organization, providing a single-tenant infrastructure that improves security, control, and customization compared to public clouds.Private cloud environment

What is a cloud GPU? Definition, types, and benefits

A cloud GPU is a remotely rented graphics processing unit hosted in a cloud provider's data center, accessible over the internet via APIs or virtual machines. These virtualized resources allow users to access powerful computing capabilities

What is cloud networking: benefits, components, and implementation strategies

Cloud networking is the use and management of network resources, including hardware and software, hosted on public or private cloud infrastructures rather than on-premises equipment. Over 90% of enterprises are expected to adopt cloud netwo

Subscribe to our newsletter

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