Localhost

In this lesson, we'll check out your local environment.

The control panel

Start the XAMPP control panel. The start the Apache web server, and the MySQL database server.

Control panel

That's it! Your PC is now acting like your Reclaim server, at least enough for this course.

What is localhost?

Your Reclaim server has a URL, like flatteringhippos.com. What about the web server your running locally? Does it have a URL?

Yes. It's localhost. There's no .com, or .org, or anything.

Try it. Open a browser, and point it at localhost. If everything's OK, you'll see a XAMPP info page.

If you don't see that, it may be that you need to change your port. A port is a number, that's an optional part of a URL. Web servers watch specific ports, waiting for messages.

The default port for web servers is 80. So localhost and localhost:80 are the same thing. See the get software lesson for help on changing the port.

Getting web pages on localhost

Remember that a URL is a path to a file, more-or-less. So, suppose you wanted to make a page with the URL localhost/animals/llamas.html (or localhost:8080/animals/llamas.html, or whatevs). Where would you put it?

Open Explorer or Finder, and look at the folder where XAMPP is installed. For me, it's on the D: drive.

Web root

There's a folder called htdocs. That's your "web root." It's where files available over localhost live.

Suppose I make a file in htdocs called rosie-truth.html.

Rosie truth file

The file's URL would be localhost/rosie-truth.html:

Rosie truth rendered

(I'm ignoring ports from now on.)

The Windows path to the file is D:\xampp\htdocs\rosie-truth.html. The root of localhost is D:\xampp\htdocs. So the URL of the file is localhost/rosie-truth.html.

Notice the file name! Lowercase, and dashes for spaces. So not Rosie truth.Html, but rosie-truth.html.

Reflect

Say I want a file with the URL localhost/animals/llamas.html. What would the Windows path of the file be, on my system?

If you were logged in as a student, the lesson would pause here, and you'd be asked to type in a response. If you want to try that out, ask for an account on this site.
Adela
Adela

The root of localhost is D:\xampp\htdocs. So localhost/animals/llamas.html would be at D:\xampp\htdocs\animals\llamas.html.

Right!

Ethan
Ethan

Hey, in URLs you use forward slashes, /. In Windows paths, you use backslashes, \. What's the deal?

Aye, you're right. In just about every context, use / to separate the folder names in a path. Microsoft chose to use \ when they launched MSDOS 1.0, decades ago. So, in Windows, use \ in file paths. URLs for files on a Windows server (which your PC is at the moment) use /, though. So it's localhost/animals/llamas.html in a browser, not localhost\animals\llamas.html.

In this course, you won't need to use \ often. Our tools are usually smart enough to handle the difference.

Running PHP on localhost

You need PHP programs to run on your server. XAMPP already set that up for you. You don't need to do anything.

W00t!

Managing localhost databases

XAMPP installed MySQL, and phpMyAdmin, a tool for managing databases. To run it, go to the CP, and click the right Admin button:

Running phpMyAdmin

phpMyAdmin is complex, so it might take a few seconds to start.

We'll talk more about phpMyAdmin in the DB part of the course.

Shutting down

If you want to shut down your servers, click their Stop buttons. Then Quit the CP.