How to Set Up a Local Web Server (Windows, Mac, Linux)

Web Server Windows Linux Mac Featured

When developing a website, a web designer needs to be able to see his webpages in the same way the end user would. Sometimes simply clicking on and viewing your HTML files in the web browser is enough, but if you want to test dynamic content, you will need to set up a local web server. Doing this is quite simple and can easily be accomplished on Windows, macOS, and Linux. There are many types of web servers available, but we use Apache in this tutorial, as it is the most common server around, very easy to set up, and compatible with all major operating systems.

Set up a local web server on Linux

Apache was designed for Unix-like operating systems. Linux falls under this category, and the installation and configuration of an Apache webserver can be done in one step.

Here we deal with the command line. Most popular distributions allow you to install Apache without compiling it from source using one simple command.

For Debian, Ubuntu, and Ubuntu-based distro:

sudo apt install apache2

For Red Hat and CentOS

sudo dnf install httpd

Once installed, navigate in your web browser to either “” or “localhost.” If it displays “It Works!” that means your Apache installation is successful.

Web Server Ubuntu Install Apache

To better understand how Apache is serving this particular webpage, let’s edit it. To do this, navigate to the root web directory of your Linux local machine.

cd /var/www/html

Open “index.html” as root with your favorite text editor.

Search for “It Works!” and change the text to something random like “Make Tech Easier!” (It could be anything really.) Make sure to save the file.

Now refresh the webpage on You should see “Make Tech Easier!” where “It Works!” was formerly.

Web Server Ubuntu Edit Default

Now that you have set up a simple web server, you can play with the configuration settings in “apache2.conf.”

sudo nano /etc/apache2/apache2.conf

Note: be aware that every time you make a configuration change, you will need to restart Apache for it to apply.

sudo systemctl restart apache2

If this does not work, you can restart it by directly executing the upstart file.

sudo /etc/init.d/apache2 restart

Set up a Local web server on macOS

The good thing about macOS is that Apache is installed on it by default. All you need to do is turn it on.

In Finder, go to “Applications -> Utilities,” then double-click on Terminal to open it.

Macos Open Terminal App

To turn on your already pre-installed Apache web server, run the following command:

sudo apachectl start

To test that our web server is running, navigate to “” or “localhost” in your web browser.

Macos Web Server It Works

We can change the content of the webpage by simply navigating to the document root the same way we did in Linux. The only thing that is different is the path location.

cd /Library/WebServer/Documents/

Now edit the “index.html.en” file using your favorite text editor. Change “It works!” to “Hello World!”

sudo nano index.html.en

If we refresh our webpage hosted on, we now see the changes reflected.

Macos Web Server Hello World

To further configure Apache web server under macOS, navigate to the “httpd.conf” file.

sudo nano /etc/apache2/httpd.conf

Like Linux, you can easily restart the Apache service using the apachectl command with root privileges.

sudo apachectl restart

Set up a local web server on Windows

Unlike Linux and macOS, Windows is not Unix-based, so there is no one-liner to install it. Fortunately, there are several install wizards that bundle things like Apache, MySQL, and PHP together to make our lives easier. One of them is XAMPP.

Note: XAMPP is available for Linux and Mac OS X, too.

Download the Windows version of XAMPP and begin the installation. Execute the installer when prompted. You can select only Apache if all you need is a web server. However, if you are planning on using a database, you may want to select MySQL as well.

Windows Xampp Installer

Continue through the installation and click “Finish” when complete. By default, the XAMPP control panel will be launched.

Windows Xampp Config Panel

Click “Start” for Apache and MySQL, if needed.

If you navigate to “” or “localhost” in your web browser, you should see the XAMPP configuration page.

Windows Xampp Webpage Configuration 1

To create a new webpage, the procedure is the same. Open notepad and create a sample HTML file. Name it “hello.html.”

Windows Notepad Hello

Save it in the document root located in “c:\xampp\htdocs\”.

Navigate to it using your web browser by going to You’ll be able to see the webpage you created.

Windows Xampp Webpage Hello

Note: WampServer is another solid option for installing Apache on Windows.


Apache is an excellent solution for building both simple and complex websites, but it is not the only option. While Apache integrates well across all three platforms, you may want to look at IIS as an option for Windows, as it supports many Windows authentication features that Apache does not. However, for simply testing the base functionality of a website, Apache is perfect.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox