Uncategorized

How to Set up a Localhost – Web Development Tutorial

If you have any intention of becoming a web developer at all, knowing how to set up a localhost is a key skill to ensure your website is ready for production.

In this tutorial, you will We’re going to briefly explain how to set up a local host as soon as possible so that you can start working with your website’s server-side functions.

Reading: How to create a website localhost

If you’re ready to learn new web development skills, let’s do it Let’s start !

Brief description

In web development, a localhost is a local server environment where we can test and use server-side scripts on our computer. We can set up our localhost environment with an Apache server application, MySQL and PHP.

XAMPP

If you are Windows or Linux user, you can download and install XAMPP from Apache Friends. You can also use XAMPP on Mac!

MAMP

If you are using Mac, I recommend installing MAMP – Mac Apache MySQL and PHP (there is a free version that absolutely good for our intentions and purposes).

Once we have our installation set up, we can start setting up our localhost environment.

Overview

Today, I’ll go through a standard MAMP setup.

Windows and Linux users; You should be able to follow the MAMP tutorial, your ‘htdocs’ directory should be in the XAMPP application directory. Depending on your system configuration, your localhost URL should be http://localhost. You would also use the XAMPP control panel.

See also  How to Cite a Website in MLA

Getting started with MAMP

See also: How to Start a Christian Blog That Reaches More People for the Kingdom

We have our MAMP folder in ‘/Applications/MAMP/’, here’s the good stuff. Navigate to the MAMP folder and launch “MAMP.app” (don’t worry about MAMP pro).

As you can see, it’s a fairly simple, easy-to-navigate application. On the left we have our server status – Apache and MySQL, these should currently be red as we haven’t started our servers yet.

If you are using XAMPP you should see the Apache web server and MySQL- Servers under the Manage Servers tab.

Starting our servers

So, let’s start these local servers!

We can do this by going to click “Start Server”.

If you are using XAMPP, you can select “Apache Web Server” and click the “Start” button.

Once the servers are loaded (the lights are green) our MAMP home page should load.

Note the URL; http://localhost:8888/MAMP/

Note: If you are using XAMPP, the localhost URL should simply be http://localhost.

See also: Building your first Support app – Part 1: Laying the groundwork

Our local MAMP server from By default, it uses port 8888 for Apache and port 8889 for MySQL (we’re not talking about MySQL server ports for the purposes of this tutorial).

Web root directory

Well, basically says http://localhost:8888 “http to localhost via port 8888”. http://localhost:8888 ‘points’ to our ‘root web directory’. Now that we’ve seen our MAMP home page and we can see that our servers are running, let’s locate our root web directory!

Let’s go back and open our MAMP folder “/applications/MAMP/” and take a closer look inside.

See also  How to Create a Windows Desktop Shortcut to a Website

So, we have our MAMP applications and a small folder titled “htdocs”. This “htdocs” folder is magic; This is the root web directory. All files (.html, .php, .css, .txt, .xml) placed in our “htdocs” or root web directory are then accessible via localhost url i.e. H. http://localhost:8888/script.php .

Adding content

Let’s create a new HTML file with the basic HTML5 structure, add some content and save it File as “home.html”.

Now let’s place our “home.html” file in our root web directory of our localhost server “/Applications/MAMP/htdocs/” and http://localhost: 8888 into your browser.

If you are using XAMPP, your htdocs folder is located in the XAMPP directory. You would then use the URL http://localhost.

You should now see “home.html” in your directory content. Click home.html and your HTML page will load. You should now understand the root web directory and its relation to our localhost.

Info

Open your text editor, create a new php file and add the following to it content and save it as ‘info.php’. Place this file in your “htdocs” directory.

See also: 7 Ways to Write Better Recipes as a Food Blogger

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button