EthicsComputerCourses
Join training +91 90532 10052

Install WordPress on Your Computer

WordPress · Lesson 2 of 30 Beginner 8 min read Updated

By the end of this lesson you will have a working WordPress site on your own computer. You will be able to log in, break things, fix them and learn without paying for hosting or worrying about visitors.

A local site is like a practice net in cricket. You can bat as badly as you like, and nobody in the stadium sees it. When you are ready, you move to a real pitch, which is a live server (next lesson).

What WordPress needs to run

WordPress is a PHP application that keeps its content in a database. So any computer that runs WordPress needs three things:

PartJobRecommended
Web serverReceives browser requestsApache or Nginx
PHPRuns the WordPress codePHP 8.3 or newer
DatabaseStores posts, pages and settingsMySQL 8.0+ or MariaDB 10.11+

These are the versions wordpress.org recommends. Older ones (down to PHP 7.4) still work, but they no longer get security fixes, so avoid them for new sites.

You have three easy ways to get all of this on your computer:

  • WordPress Studio: a free desktop app from WordPress.com for Windows, macOS and Linux. It creates a site in one click. Best for absolute beginners.
  • XAMPP: a free bundle of Apache, PHP and MariaDB. You install WordPress by hand, which teaches you how things really work.
  • WordPress Playground: runs WordPress inside the browser at playground.wordpress.net. Nothing to install, but the site is temporary.

We will use XAMPP in this lesson because the manual steps are the same ones you will use on real hosting.

Step by step with XAMPP

Step 1: Install and start XAMPP. Download XAMPP from the Apache Friends website and install it (on Windows the default folder is C:\xampp). Open the XAMPP Control Panel and click Start next to Apache and MySQL. Both names should turn green.

Step 2: Check the server. Open http://localhost/ in your browser. You should see the XAMPP welcome page. If you see "This site can't be reached", Apache is not running.

Step 3: Download WordPress. Go to wordpress.org/download/ and download the zip file. Extract it. You get a folder called wordpress.

Step 4: Copy the files. Copy the wordpress folder into C:\xampp\htdocs\ and rename it to coaching. The path is now C:\xampp\htdocs\coaching\wp-admin and so on. The folder name becomes part of your local address.

Step 5: Create an empty database. Open http://localhost/phpmyadmin/, click Databases, type coaching_local, choose the collation utf8mb4_unicode_ci and click Create. If you prefer typing, the SQL tab accepts this:

SQL
CREATE DATABASE coaching_local
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

utf8mb4 lets the database store every language and symbol, including Hindi text, the ₹ sign and emoji in comments. XAMPP ships MariaDB, which works like MySQL for WordPress, so this command runs on both.

Step 6: Start the installer. Open http://localhost/coaching/. WordPress notices that it has no settings yet and shows a language list. Pick English (or another language) and click Continue.

Step 7: Enter the database details. WordPress asks five questions. On a default XAMPP setup use these values:

FieldValue on local XAMPP
Database Namecoaching_local
Usernameroot
Passwordleave empty
Database Hostlocalhost
Table Prefixwp_ (or something like cc_)

Click Submit, then Run the installation. An empty root password is acceptable only on your own computer. A live server must always use a separate database user with a strong password.

Step 8: Fill in the site details. Enter a Site Title such as "Bright Future Coaching", an admin username (not admin), a strong password, and your email. Click Install WordPress. You should see "Success!" and a Log In button.

Step 9: Log in. Open http://localhost/coaching/wp-admin/ and log in. You now see the Dashboard. Visit http://localhost/coaching/ in another tab to see the public site with the default theme.

What the installer wrote: wp-config.php

During Step 7, WordPress created a file called wp-config.php in the coaching folder. It holds the database connection and a few important settings. A trimmed version looks like this:

PHP
<?php
// Database connection
define( 'DB_NAME', 'coaching_local' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );

// Unique keys and salts (long random strings, different on every site)
define( 'AUTH_KEY', 'long random text generated by WordPress' );
// ...seven more keys like this...

$table_prefix = 'wp_';

// Turn on debug messages on your own computer only
define( 'WP_DEBUG', true );

/* That's all, stop editing! Happy publishing. */
require_once ABSPATH . 'wp-settings.php';

Each define() creates a constant, which is a named value that never changes while the page loads. The keys and salts are random text that protect login cookies. Never share them and never copy them from another site.

If WordPress cannot write the file (this happens on some servers), it shows you the text and asks you to create wp-config.php by hand. You do that by copying wp-config-sample.php to wp-config.php and filling in the same values.

Checking your install

After logging in, open Tools > Site Health > Info. It has expandable sections. Open three of them and look for these rows:

Text
WordPress   > Version          7.1.4
Server      > PHP version      8.x.x
Database    > Server version   10.x.x-MariaDB

Your exact PHP and MariaDB numbers depend on the XAMPP version you installed. If Site Health warns that your PHP version is outdated, install a newer XAMPP before you go further.

Older code and other ways

You may see older guides that ask you to create the database with a utf8 (three-byte) character set. That cannot store every character, so always use utf8mb4 today.

Some tutorials also use Local (a free app by WP Engine) or Docker-based tools such as wp-env. They all do the same job: give WordPress a web server, PHP and a database. Pick one and stick with it while you learn.

Common mistakes

  • Apache will not start. Another program (often Skype or IIS) is using port 80. Close it, or change Apache's port in XAMPP.
  • "Error establishing a database connection". The database name, user or password in wp-config.php is wrong, or MySQL is not running in XAMPP.
  • Opening the folder in File Explorer instead of the browser. Double-clicking index.php will not work. Always use http://localhost/....
  • Using admin as the username. It is the first name attackers guess. Use something personal, even locally, to build the habit.

Key points

  • WordPress needs a web server, PHP and a MySQL or MariaDB database.
  • WordPress Studio is the fastest local option; XAMPP teaches the manual steps you also use on hosting.
  • The installer creates wp-config.php, which stores database details and secret keys.
  • Use utf8mb4 for the database so every language and symbol works.
  • An empty database password is acceptable only on your own computer.
  • Tools > Site Health > Info shows your WordPress, PHP and database versions.

Exercise

Install a second local WordPress site called shop in XAMPP. Use a database named shop_local and the table prefix sh_. After installing, find the line in wp-config.php that holds the prefix and write down its exact text. Then open phpMyAdmin and check that the new tables start with sh_.

Show solution

Create the database first:

SQL
CREATE DATABASE shop_local CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

After the installer runs, wp-config.php contains:

PHP
$table_prefix = 'sh_';

In phpMyAdmin the database now lists tables such as sh_posts, sh_options and sh_users. A different prefix lets two sites share one database without clashing, although separate databases are cleaner.

Quick Quiz

1. Which three things does WordPress need to run?

2. Which file stores the database name and password?

3. Why should you create the database with utf8mb4?

4. When is an empty database password acceptable?

Learn WordPress with a mentor

Free lessons get you started. Our WordPress & Website Building training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call