How to code your first website - Part 1

How to code your first website - Part 1

Building a website is all about coding, but before digging into that we need to configure a web server to host our website.

Configuring a web server

Starting from the OS of your computer, because I don’t want to waste your time browsing for the best web server for Windows or Mac OS or Linux, I did some research and found one that is cross-platform and it’s doing all we need.

What does a server do? Well depending on the type of server, they do different stuff, but one thing is for sure all servers respond to requests. And this is what we need. When the user opens a website from the browser, it creates a request, sends it to our web server, it is processed and return data to the client browser in different formats. In our case, our web server will process the requests and depend on the page requested it will run PHP software installed on our server and read the code we wrote. In most cases, the code is generating HTML code which is then returned to the client. The browser then reads the HTML and displays a nice website.

Why do we need PHP?

You don’t. You can just add your HTML page to your server and it will automatically return it. But by using PHP you can add some dynamics to your website. Like adding a search box, subscribe form, possibility to sign-up and so many others.

Configuring our first web server

After you install and open XAMPP. You will notice Apache Module. This is our web server. The one processing our requests. Click Start. Now that we have a local web server running you can navigate to C:/xampp/htdocs or by clicking Explorer in XAMPP. This is where the root of your server will be. To test our server let’s create here a simple HTML page.

<!-- index.html -->
<!DOCTYPE html>

Save the file with the following name: index.html.

Now open the browser and type http://localhost/ and now check also http://localhost/index.html. It works even without specifying the file name because Apache knows to look for an index file in case no file is requested.

Congratz! You just created your first website on a real server. See you in part 2 of this tutorial where we’re going to add some dynamics to this page. The second part of the tutorial how to build a website

Share on

See Also
Send us a few words.
What would you like to see different on this blog?