Downloading and configuring a local WordPress installation
The next component of our local development environment is to install WordPress on your local web server to run a fully working website and have all of its files hosted locally.
WordPress has always prided itself with its easy five minutes installation process. Installing it on a local web server is even easier and quicker than it would be on a live remote server. This recipe covers the creation of a MySQL database to store all data related to our new WordPress installation and the actual setup process.
Getting ready
This recipe assumes that you have a local web server installed on your computer. This web server can be a fresh install performed using the previous recipe or can be from a previous installation. The steps in the following section are written with a focus on new local web servers. If you have created a new account to access the MySQL database or changed the root user's password, some of the steps will change slightly. The location of the phpMyAdmin tool might also be different if you are using a different web server than XAMPP. You should refer to your web server's documentation to find out what that address is.
How to do it...
- In the web browser, navigate to the address
http://localhost/phpmyadmin/
to access your web server's database administration tool. - Click on
Databases
tab inphpMyAdmin
. - Type the name of the new database to be created in the empty field following to the words
Create database
. In this case, we will use the namewordpressdev
:

- Click on the
Create
button to complete the database creation process. - Download the latest WordPress installation package from the official WordPress website (https://wordpress.org). The download link can be found on the very first page of the website and the download package will work on any web server, local, or remote.
Note
The following instructions have been tested against WordPress version 4.8. While the installation process does not usually change much between versions, there may be slight differences in these steps on newer versions.
- Extract the WordPress archive file contents using your favorite file archiver utility or your operating system's built-in capabilities.
- Copy the contents of the resulting
wordpress
folder to your local web server's web content directory (c:\WPDev
, if you followed the previous recipe). You should not copy thewordpress
folder itself unless you want the address of your WordPress website to behttp://localhost/wordpress
. - Direct your web browser to
http://localhost
to start the WordPress installation process. - Select your preferred language and click on
Continue
. - On the next page, click on the
Let's Go
button to start your development site's configuration. - Update the
Database Name
field to reflect the name of our newly-created database (wordpressdev
). - Set the MySQL
User Name
toroot
. - Delete all the characters from MySQL
Password
to leave it empty, since local MySQL server root accounts are typically configured without any password. - Leave the
Database Host
field with its default value (localhost
). - Change the
Table Prefix
field from its default value towpdev_
:

- Click on the
Submit
button to validate the information entered. If any parameters are not entered correctly, or if the WordPress installation process cannot correctly access your database server, it will display an error page and give you an opportunity to make corrections. - Click on the
Run the install
button for WordPress to create the required table structure in the designated MySQL database. - Specify a
Site Title
(for example,Development Site
). - Set
Username
for the admin user. For increased security, it's always best to choose a username that people would not be able to easily guess. Obvious names such as admin or administrator should be avoided. - Optionally, change the randomly generated password with a password of your own choice. If WordPress determines that your new password is weak, you will need to check the additional checkbox that appears to confirm that you want to use a weak password.
- Enter your email address in the appropriate field (although no email will actually be sent on most local development installations).
- If you are configuring a live external development server, check the
Discourage search engines from indexing this site
option, since we do not want this development site to appear anywhere. - Click on
Install WordPress
to complete the installation and you will be automatically logged in to the site's WordPressDashboard
.
- Click on the
Development Site
link in the Dashboard admin bar to see your new site:

How it works...
In the first few steps, the phpMyAdmin interface is used to create a database on the local MySQL server. This web-based database management tool comes bundled with XAMPP and most other web servers. The http://localhost/phpmyadmin
address will always take you to the database administration tool, even if you relocate your web server's document root directory as documented in the previous recipe.
Once a database is created and the WordPress files have been copied to the correct location, pointing your browser to the local web server gets it to search through the document root directory to find HTML files to send back to the browser or PHP files to execute. In the case of WordPress, the web server finds the index.php
file and executes it using its PHP interpreter. As the WordPress code is executed, it checks if a configuration file is present and launches the installation process when it does not find one. The WordPress code does not see any difference between the local web server that we are running it on and a remote live web server that would be accessible anywhere online.
While we specified an email address for the administrator during the installation, many local web servers are not configured to send out email messages so we will never receive any email communication in these cases. It is preferable to use a remote server when developing and testing email functionality in a plugin.
Once this recipe has been completed, you will have a functional WordPress installation in place.