Recently, one thing I find myself doing more often is building local WordPress environments on my computer for clients. Unfortunately, I’ve run my database cap on my own hosting, so I can’t host working versions of their sites online. To get around this, I turned my computer into a local WordPress environment through the help of XAMPP, or the LAMP environment. When you do this, you not only have the ability to just host a multitude of sites on your computer, but you’re also able to play around with themes, theme modifications, and styling.
What Exactly is all this Mumbo Jumbo?
Let’s take it letter by letter –
Apache is web server software. Basically, it’s what delivers you to your destination when trying to access a website. By setting it up locally, we’re able to send ourselves to a viewable version of the content we’re creating, and it returns the data for us as well.
MariaDB is your database server. This is where all the data for your WordPress configuration is held (usernames, passwords, posts…) essentially, all your tables.
PHP is a scripting language used in web development. PHP is a server-side language – just think of it as the “computer language” that’s parsed in all of this.
Perl is a programming language, plain and simple.
XAMPP takes all of this, and bundles it in a nice package that you can deploy locally without the hassle of dealing with web hosting. Now let’s get started.
Visit the Apache Friends website and download your copy of XAMPP. Optionally, install filezilla because it’s bundled in and it’s a great FTP program that you can have on your computer. Once this is finished, you’ll be faced with the XAMPP control panel – go ahead and start up both Apache and MySQL.
Installing the Database
Click on the “Admin” button of MySQL to start up phpMyAdmin. This is where we will be creating the database that our WordPress environment is going to communicate with. Once in the admin panel, click “New” on the left-hand side to create the database. Enter a database name (please just use all lowercase and no spaces), keep it on Collation and hit “Create.” Once this is done, you can close this out because we now have an empty database to fill in with information. Make sure you remember the name of the database you created because we’re going to use that in the WordPress configuration file.
Head on over to WordPress.org and download the latest copy of WordPress. Extract the folder from the zip file in XAMPP’s “htdocs” folder. This folder can be found by locating your xampp installation folder (it’s in the root). Give the folder a name other than “WordPress” (I named mine gregoryrocco) and go inside of it.
In here, we need to first rename the file “wp-config-sample.php” to just “wp-config.php.” We also need to do some edits to this file, so pick up a free text editor like Visual Studio Code and open up this file.
When you’re inside this file, you’re going to edit the following entries:
-Your database name to whatever you called your database in MySQL
-Your username to “root”
-Your password to nothing.
It should look like this after you’re done (remember, where “gregoryrocco” is should be your own database name)
Once this is all saved and packed away, open up a web browser (like Chrome… please use Chrome) and type in “localhost/yourfoldername” so in my case it would be “localhost/gregoryrocco” because that’s what I named the folder in htdocs. If this doesn’t make sense, you glanced too quickly through the first part about naming your folder in htdocs. Once you’re there, WordPress should prompt you to install it. Congratulations, you’re now running WordPress locally.
-You won’t be able to run your site unless both Apache and MySQL are started up in the XAMPP control panel. Once you’re done making edits for the day, make sure to stop these because they can be real resource hogs.
-This isn’t the only site you can run locally. You can run as many sites as you want – just follow these steps back again and you’ll be able to set another one up.
Help, I Have a Mac and Installing Themes and Plugins Isn’t Working!
Well, you need to take a couple of extra steps if WordPress is responding with “To perform the requested action, WordPress needs to access your web server.”
-First, open your terminal, type “whoami” and hit enter. This should give you the exact username of your mac.
-Then, type in the following command: “sudo chown -R yourusername /Applications/XAMPP/xamppfiles/htdocs” and hit enter. Remember to replace “yourusername” with the username you acquired by typing in “whoami” earlier
-Open up that location we just modified (Applications/XAMPP/xamppfiles/), right click on htdocs and click “get info.”
-Once here, make sure that everyone in the “Sharing & Permissions tab” has “Read & Write” privileges. Click on the gear and hit “Apply to enclosed items.” Hit the lock to save changes.
-Then open up your terminal and type in “sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
-A cool Apache file will open up in your terminal – hit CTRL + W to find “User daemon” and press enter
-Replace “User daemon” with “User yourusername” and “Group daemon” with “Group admin” (remember, no quotes and yourusername is from the whoami request)
-Save by pressing CTRL + O and quit by hitting CTRL + X. Restart Apache (stop, start) and you should be up and running again.