Part 7 – Installing WordPress

November 30, 2024

!Series: Local Environment Apache phpMyAdmin WordPress

In this final section, we will be installing WordPress on our test-1 site.

Downloading WordPress

Download the WordPress files at this link. You will want to use the option for downloading and installing yourself, not one that talks about setting it up on an existing provider.

Screenshot of browser

WordPress download page

Extract the files. Generally, there’s an outer folder that will be something like wordpress-6.7.1 and an inner folder just called wordpress that contains files like wp-activate.php. We’ll be moving the inner folder.

Move the wordpress folder into the www folder. When this is done, both of the following should be true:

  • There should be three folders in C:\Development\www\test-1: phpMyAdmin, SSL, and wordpress
  • The directory C:\Development\www\test-1\wordpress\readme.html is a valid path

Screenshot of File Explorer

Contents of test-1 folder

Setting Up a Database

Before we get started, let’s look at the WordPress readme file (readme.html). We will be following the “Famous five-minute install” instructions.

Screenshot of browser

Segment from the WordPress readme file

Following those instructions, go to https://test-1.local/wordpress/wp-admin/install.php. You should see a screen that starts with “Welcome to WordPress”.

Screenshot of browser

WordPress installation welcome screen

The first installation screen tells us that we need to set up a database for WordPress before we can continue, since we don’t have a database name, username or password for this install specifically yet.

For more details about these instructions, refer back to Part 5. Go to https://test-1.local/phpmyadmin/ and log in with the root password. Click on “New” in the left sidebar to create a new database.

We can choose any name that isn’t taken. You shouldn’t use a database with existing tables. I’ll make one called test1_wp. If you don’t have a strong reason to do otherwise, WordPress recommends utf8mb4_general_ci as your collation. Click “Create”.

Screenshot of browser

Creating a database in phpMyAdmin

You’ll see the table creation panel, but we won’t be creating any tables right now. What we will do is create a user that can only access the database we just created. We won’t go over the steps to do this in detail, because it’s covered in Part 5, but here’s the important parts.

First, we’ll create a new user account but not grant it any permissions. (I’m calling the user test_wp_admin.)

Second, we will grant database permissions and database-specific privileges for the test1_wp database.

To make sure everything works, log out of phpMyAdmin and log back in with the newly created user. You should be able to see the new database and information_schema, but not any of the other databases.

With that done, we’re ready to install WordPress.

Installing WordPress

Go back to https://test-1.local/wordpress/wp-admin/install.php. It may bring you back to the same screen, or might show you the language selection screen.

Proceed to the screen where you need to enter your database details. We’ll use the following info:

  • For Database Name, use the name of the database just created (test1_wp)
  • For Username, use the name of the user you created and gave permissions to access that website (test1_wp_admin)
  • For Password, enter the login password for that user
  • For Database Host, use localhost
  • For Table Prefix, use the default setting (wp_)
    • You would change this if you are going to be running more than one WordPress installation in the same database. We are running multiple sites, but each WordPress install has its own database.

Screenshot of browser

WordPress install database connection screen

Click “Submit.”

You should see a confirmation screen with the button that lets you run the rest of the installation. In addition, if you look at your wordpress folder, you will see that a new file called wp_config.php was created. If you look inside that file, you will see the database information you just submitted. (You could create your wp-config.php file manually too, but we’re using the easy method here.)

Screenshot of browser

WordPress database connection successful

Fill in the information on the WordPress welcome screen. This will create the username and password that you will use to log into WordPress. You do need to enter an email, even though it won’t go anywhere since it’s a local site.

Screenshot of browser

WordPress welcome screen

You should get a confirmation screen that shows you everything has installed successfully. Log into your site to make sure your login is working as expected.

You should be able to view your site. There’s still a problem, though. Our WordPress site is located at https://test-1.local/wordpress/. We actually want our WordPress site to display at https://test-1.local/. We’ve got a few more steps to fix that.

Making Our WordPress Site Home

Back in Part 3, we set up virtual hosts so we could use one installation of Apache to serve multiple sites. As part of that process, we told Apache where to serve files from and we gave it permission to access that directory. Currently, that part of httpd-vhosts.conf (C:\Development\Apache24\conf\extra) looks like this:

DocumentRoot "${DOCROOT}/test-1"

<Directory "${DOCROOT}/test-1/">
    Require all granted
</Directory>

However, now we need to change that since we want this is site served out of the WordPress directory. Change that part of the httpd-vhosts.conf file to:

DocumentRoot "${DOCROOT}/test-1/wordpress"

<Directory "${DOCROOT}/test-1/wordpress/">
	Require all granted
</Directory>

Note that you must not have a slash at the end of the DocumentRoot directive and you must have one at the end of the Directory directive.

Restart Apache and try visiting https://test-1.local/. It is serving your site, but it looks odd—images that came with the theme will be missing, for example. (This is more obvious with some themes than others.)

The issue is that Apache is serving everything from the WordPress directory, but WordPress doesn’t know how to navigate to its own files now. Fortunately, WordPress has configuration options that can fix this.[1]

Go to C:\Development\www\test-1\wordpress and open wp-config.php. Find the section that starts with “Add any custom values between this line”. Add these two lines, so that section looks like this:

/* Add any custom values between this line and the "stop editing" line. */

define('WP_SITEURL', 'https://test-1.local');
define('WP_HOME', 'https://test-1.local'); 

/* That's all, stop editing! Happy publishing. */

Save the file and refresh your page. Everything should work now.

Conclusion

That’s it for this series. Thank you for reading along and good luck with your own projects!

Further Reading

Notes

[1] Thank you to James Blond on Apache Lounge for pointing out the wp-config solution here.

Posted In: Tutorials