Web

How do I set up a web server?

Updated 2026-08-14

✓

Quick answer

To set up a web server, install server software like Apache or Nginx and configure it to serve your website files.

This guide provides steps to set up a web server using popular software options, along with potential caveats and frequently asked questions.

Steps

  1. 1

    Install Apache on Ubuntu

    Run 'sudo apt update' followed by 'sudo apt install apache2' in the terminal.

  2. 2

    Install Nginx on CentOS

    Use 'sudo yum install epel-release' and then 'sudo yum install nginx' in the terminal.

  3. 3

    Configure Apache

    Edit the configuration file located at '/etc/apache2/sites-available/000-default.conf' to set the document root.

  4. 4

    Start the Web Server

    Use 'sudo systemctl start apache2' for Apache or 'sudo systemctl start nginx' for Nginx.

Installation of Web Server Software

Choose a web server software such as Apache or Nginx. Download and install it according to your operating system's guidelines.

Configuration

Configure the server settings, including document root, server name, and port number. Ensure that the server is set to start on boot.

Testing the Server

After installation and configuration, test the server by accessing it via a web browser using the server's IP address or domain name.

Watch out for

  • Ensure your server is secured against unauthorized access.
  • Configuration paths may vary based on the operating system and version.

FAQ

What is the difference between Apache and Nginx?

Apache is process-based and suitable for dynamic content, while Nginx is event-driven and excels in serving static content.

How do I secure my web server?

Implement SSL/TLS certificates, keep software updated, and configure firewalls to restrict access.

Can I host multiple websites on one server?

Yes, both Apache and Nginx support virtual hosts, allowing you to host multiple sites on a single server.