The Expert Crew

Menu
  • Home
  • Android
  • Apple
  • Linux
  • Windows
  • Reviews
  • How To
  • Gaming
    • Xbox
    • PS
    • Nintendo Switch
  • Web

Binance: Buy BTC & 600+ Crypto Ethereum, USDC, XRP and Altcoins with USD Securely

Join Now & Claim Free Bitcoin
Home
Linux
How to Set Up a Local Web Server (Windows, Mac, Linux)

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

August 13, 2021

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

When developing a website, web designers must be able to view their web pages in the same way as end users. Sometimes you just click and view the HTML file in a web browser, but if you want to test dynamic content, you need to set up a local web server. This is very simple and can be done easily on Windows, macOS and Linux. There are many types of web servers available, but we used Apache in this tutorial because it is the most common server, very easy to configure, and compatible with all major operating systems.

Related : Nginx vs Apache: Which Serves You Best?

Set up a local web server on Linux

Apache is designed for Unix-like operating systems. Linux falls into this category, and the installation and configuration of the Apache Web server can be done in one step.

Here we deal with the command line. The most popular distribution allows you to install Apache without compiling it from source using simple commands.

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 “127.0.0.1” or “localhost.” If it displays “It Works!” that means your Apache installation is successful.

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 “Hello it’s Me!” (It could be anything really.) Make sure to save the file.

Now refresh the webpage on 127.0.0.1. You should see “Hello it’s Me!” where “It Works!” was formerly.

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 apache2 restart

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.

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 “127.0.0.1” or “localhost” in your web browser.

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

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
How to Set Up a Local Web Server (Windows, Mac, Linux)

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

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

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 need to install an eyeliner. Fortunately, there are several installation wizards that combine things like Apache, MySQL, and PHP to make life easier for us. One of them is XAMPP.

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

Download the Windows version of XAMPP and start the installation. Run the installer when prompted. If you only need a web server, you can only choose Apache. However, if you plan to use a database, you can also choose MySQL.
How to Set Up a Local Web Server (Windows, Mac, Linux)

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

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

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

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

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

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

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

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

Related: How to Install and Run the Nginx Server on Windows

Conclusion

Apache is a great solution for creating simple and complex websites, but it is not the only option. Although Apache can integrate well across all three platforms, you may want to use IIS as an option for Windows because it supports many Windows authentication features that Apache does not support. However, in order to simply test the basic functions of a website, Apache is perfect.

Related : How to Access Linux Ext4 Partition from Windows

Share
Tweet
Pinterest
Reddit
Tumblr
Vkontakte
Prev Article
Next Article

Related Articles

How to Turn Windows 10 Into Windows 11
You can dress Windows 10 like Windows 11 using a …

How to Turn Windows 10 Into Windows 11

How to View Screen Resolution on Windows 11
In Windows 11, how do I check the screen resolution? …

How to View Screen Resolution on Windows 11

How to set PhysX Configuration in Nvidia Control Panel on Windows 10
A GPU is found in many computers. These systems may …

How to set PhysX Configuration in Nvidia Control Panel on Windows 10

How to Compress Files with zstd Utility in Linux [Linux / Ubuntu]
  Although there are many graphical and command-line data compression …

How to Compress Files with zstd Utility in Linux [Linux / Ubuntu]

How to fix You need a WIA driver to use this device error on Win11/10
Many Windows users while connecting a scanner, printer, or some …

How to fix You need a WIA driver to use this device error on Win11/10

No Responses

  1. Pingback: How to Stop Your PC from Making Random USB Noises

Win an iPhone 13 Pro Max!

Related Posts

  • How to Restore Chrome Tabs After Restart
    How to Restore Chrome Tabs After Restart

Featured Products

  • Hostinger Web Hosting Review
    Hostinger Web Hosting Review
  • HostGator Web Hosting Review
    HostGator Web Hosting Review
  • Bluehost Web Hosting review
    Bluehost Web Hosting review
  • Best Web Hosting Services: The Top Web Hosts of 2022
    Best Web Hosting Services: The Top Web …
  • Binance Review 2022 – Should You Use It?
    Binance Review 2022 – Should You Use …

The Expert Crew

Linux & Windows 10/11 & Android Tips, Tricks, Help, Support, Downloads, Features
Copyright © 2022 The Expert Crew
About us | Contact Us | Disclaimer | Privacy Policy | Terms of Service