Currently, 33% of the internet is built off the WordPress platform. If you are not sure what WordPress is, more information can be found here. Since it is such a popular web platform, if you are interested in web development, it is pretty crucial to at least know the basics, and this starts with setting up a testing environment. To accomplish this we need to: set up a local server, install WordPress on it, and finally set up the WordPress environment.
Set up a local server
If you already have a PHP environment set up then you can skip this step and go straight to getting WordPress on your local server. If not, we will go ahead and touch on how to do so in order to get started with WordPress, and more information can be found in our article “Getting Started With PHP: Setting Up A PHP Environment”.
In order to get started with WordPress we first have to have a local web server to install it on. In order to do this, we are going to install the Apache environment, XAMPP. This has everything we will need to get started including an Apache web server, MySQL, and a PHP interpreter. To install the XAMPP development environment the software can be found here. Let’s go ahead and download the version we need and then go through the steps to install it. If you are using windows the process is pretty foolproof, and if you are installing it on a Linux machine, instructions on how to do so can be found here. Once you go through the installation steps (just got with the default setting for now), you’re done. You have successfully installed your local web server. Now we need to actually get WordPress on the server.
Getting WordPress on a local server
Now that our web server is installed, the next step is to get WordPress on it. To do this we first need to download WordPress, which can be found here. Download the zip file, and move it to the ‘htdocs’ folder inside the XAMPP directory. If you are unsure of what this means, when we installed our web server a directory called ‘xampp’ was created on our computer. Inside this directory is a folder called ‘htdocs’, and inside this folder is where we save all of our web projects, including WordPress. So, once our WordPress zip file is inside our ‘htdocs’ we can go ahead and unzip it. We should be left with a WordPress Folder inside our ‘htdocs’. You can name this folder whatever you want, but for the sake of this article we are going to name ours ‘WP’. At this point we haven’t technically installed WordPress, but we now have it on our web server, and the only step left is to set up the environment and officially install it.
Setting up the environment
To set up our WordPress environment we first need to make sure that our WordPress installation can access our database. In order to do this, we need to go inside our WordPress folder ‘WP’ and find the file ‘wp-config-sample.php’. Rename this file ‘wp-config.php’, and open it inside a text editor. It should look like this…
Go ahead and replace ‘DB_NAME’ with the name of your database, which in our case is ‘wp’. Then change the username and password to whatever you want. We personally recommend leaving the username as ‘root’ and changing the password. Note: If you don’t have a database created you may have to create on in your phpmyadmin which can be reached by searching “localhost/phpmyadmin” in google. You’ll go to your databases and create a database that matches what you specified in your config file.
Once you’ve changed the database information, we are ready to open WordPress. To do this, go to your browser and, in the top bar, enter ‘localhost/WP/’. It should bring us to a screen that looks like this…
Select your language, click continue, and on the next screen enter your username and password details. Finally click ‘Install WordPress’ and that’s it, we’re all done. We have successfully installed and set up a local WordPress environment. To access the admin panel, simply make sure XAMPP is running with Apache and MySQL and in the browser go to ‘localhost/wp/wp-login.php’ and it will bring you to the admin login screen.