Most hosting companies will set up your WordPress installation or have automation scripts in their admin panel (cPanel, etc.) for the job. However, setting WordPress up is as easy as can be and is a skill worth having, as it can be extremely useful to run WordPress on your dev box. At the time of writing this, the latest version is 6.6.2.
In this tutorial:
Required knowledge:
Take screenshots of the setup & configuration screens as you go or write the details down.
Requirements
This tutorial assumes that you have a computer set up as a dev machine with the following installed and configured:
- Apache HTTP Server
- PHP
- MySQL
- phpMyAdmin or MySQL Workbench
See the WAMP (LAMP) post for more.
Create the MySQL database
Open phpMyAdmin or MySQL Workbench and create a MySQL database.
See the CREATE DATABASE statement tutorial.
Create a database user account
WordPress will need to connect to the MySQL database. To do this, you must create a database user account (“DUA”):
- Create user
- Grant privileges
- Flush
Despite the fact that the official docs tell you to grant all privileges to the DUA [1], I think it is bad practice to do so (or use your admin credentials) as if someone hacks your WordPress they would have full access to all your databases, let alone your WordPress database.
Importantly, your DUA should not have GRANT privileges and should not have privileges to any other databases on your server. Read about the “Principle of Least Privilege” (POLP) in this excellent article, What Is The Principle of Least Privilege in WordPress [2]
See the CREATE USER & GRANT PRIVILEGES in MySQL tutorial.
Download WordPress
Download WordPress here for free: https://en-gb.wordpress.org/download/
The download page has links to resources for installing and using WordPress. [4]
Unzip
Assuming your htdocs directory is empty, simply unzip the downloaded file into your htdocs folder:
htdocs
⊢ wp-admin
⊢ wp-content
⊢ wp-includes
∟ index.php
Configure
The installation is done using a set-up wizard in the browser. Open your browser and enter 127.0.0.1 or localhost in the address bar to load the WordPress Installation Welcome screen:
- Click the Let’s go! button
- Enter the database settings & click the Submit button
- Click the Run the installation button
References:
- WordPress Developer Resources – Advanced Administration Handbook (2023) Creating Database for WordPress. Available at: https://developer.wordpress.org/advanced-administration/before-install/creating-database/ (Accessed: 20 October 2024).
- Hosting, S. W. (no date) What Is The Principle of Least Privilege in WordPress and Why It’s Important, SiteGround. Available at: https://world.siteground.com/blog/principle-least-privilege-wordpress/ (Accessed: 20 October 2024).
- Swisher, J. (2023) WordPress Database: A Detailed Guide with Best Practices, Jetpack. Available at: https://jetpack.com/blog/wordpress-database/ (Accessed: 20 October 2024).
- WordPress.com (2024) Get WordPress English (UK). Available at: https://en-gb.wordpress.org/download/ (Accessed: 20 October 2024).