When you develop locally, you’re developing on your computer. Unlike using standard HTML and CSS website, which can easily be developed on your computer, WordPress requires certain resources: My Apache, MySQL, and PHP.
MAMP creates a local development server, that allows WordPress to run on your computer. The reason you would want to develop locally is that you can develop without any preying eyes – the website is not live and only for your eyes to see. You can release it only when you feel it’s ready.
I’m using MAC, therefore the software I’ll be using is dedicated to macOS, called MAMP. If you’re a Windows user, you can check WAMP instead. Unfortunately, this article will only cover setting a local server using MAMP.
Step 1: Downloading MAMP
There are two flavors of MAMP: standard and pro. The regular version is free and has all the necessary functionality to do everything you need to develop a WordPress website. On the other hand, you can start with the paid version, but really… Who does that?
The first step is the easiest one. Simply select the version of MAMP accordingly to your operating system. In my case, I’m using MAC, so I’ll go with that option. Once downloaded, install the system.
Once installed, you’ll be able to find MAMP on the Applications. Simply filter your applications by date to find it easily. Note: there will be two MAMP files – the application pro version called MAMP PRO and the file folder for the MAMP. Select the latter. As of the day of writing, the MAMP comes with the free PRO version that has 14 days of trial.
Once in the folder select MAMP logo to launch the program and press Start Servers to start.
When the servers are all up and running, a new site will open on your browser. In the site, you’ll need to find your MySQL section where you’ll find a Host name, user and password, that will be needed in the next step.
Step 2: Downloading WordPress
First of all, I need to mention, that there are 2 WordPress websites. One ending with the .org and the other one with the .com. The latter is the blogging platform where you can start your blog for free and use the functionality of WordPress system. What you’d want to do is to go to https://wordpress.org/ instead and download WordPress to your computer.
Once downloaded extract the .zip file and drag & drop the folder to the htdocs folder in the MAMP. When done, rename the file to your own preferences as you’ll need it in future steps. For myself, I renamed the folder wp-dev.
Step 3: Connect WordPress to MAMP
Alright, so far so good. At this point, go back to the MAMP site and under the TOOLS select PHPMYADMIN. Now we’ll be making sure that WP files would be able to communicate with the database. Unfortunately, we don’t have a database right now, that’s why we need to create one.
Go to the Databases and create a new database by giving it a name and pressing Create. You can name your database however you want, but it’s always nice to know what’s what so I’ll go with wp-dev_db (db here stands for “Database”).
You’ll be able to see your new database on the left-side panel. You’ll also see that “No tables are found in the database”. That’s okay because WordPress files are basically are empty template files and they get their information from the database. Since this tutorial is not for web developers, I won’t go into details. All you need to do at this point is just to follow along.
Now, go back to the MAMP folder > htdocs > your WordPress folder. Search for the wp-config-sample file and delete the sample part as it only is a sample of what is supposed to be.
Now, in order to edit the file, you’ll need a code editor. In my case, I’m using a free code editor for MAC called Brackets. Brackets is a modern, open-source text editor that understands web design. The open-source is the most important point here as this means that many people are working voluntarily on this software for people to access it for free. There are many paid code editors, but for this purpose, Brackets is more than enough. Even for web developers who are only learning, it’s advised to start with this code editor as it’s, once again, free and simple to use.
In the wp-config you’ll find these lines of code, but don’t let that scare just yet. It’s a lot simple than it looks. In the document, search for the line of code if says:
define( ‘DB_NAME’, ‘database_name_here’ );
At this point, you’d want to change the name to the one you’ve created on the PHPMYADMIN. In my case, it’s going to be wp-dev_db.
Next, you’ll need your username and the password that you found on the MAMP page. Luckily, when you’re using MAMP, the password and the username will always be root. Simply edit the MySQL username and password code lines in the wp-config you have opened. Your line of code should look like this:
Finally, you’ll need to pass the security system of WordPress and follow the instructions found below in the code to authenticate WordPress. To authenticate, you’ll need to copy-paste unique phrases, that can be found in the link mentioned in the lines of code. Once done, save the file.
Overall, there are a lot more steps you can take to make your WordPress secure and safe, but this is a topic for another article. Right now, you’d still be running your site locally, so you’ll be safe no matter what.
Step 4: Launching WordPress
Finally! The time has come! After all these steps, you’ll finally be able to access your website! Well, almost…
Remember when I said to name the WordPress file folder so you could use it in the future steps? Now is the time. Open your browser and type http://localhost:8888/ and the name of your WP folder. Voila! WordPress is ready to be installed.
Finally, after pressing Continue fill-up all the necessary information for your website. At this point, you might as well choose to discourage search engines from indexing your site. Remember, this site is only for your eyes. Moreover, the site will only be visible for you, no one else will be able to access it, but still, you can never trust Google.
And just like that, you have your own WordPress website, ready to use, on your localhost server!