I’m making a WordPress/Joomla/Droopal/etc. site locally. How do I test/set up the databases? Do I need to download and learn MySQL?
So I’ve been getting this question a lot from friends, peers and just random people on the internet learning and/or experimenting with client-side web development independently. The answer is, well, no. If you’re a front-end developer primarily focused with client-side functionality, you can build sites locally on, and/or convert local sites to, popular CMS’s that rely on databases and web servers to fetch dynamic content without learning much about the backend.
This is thanks to two useful pieces of software: XAMPP for Windows, and MAMP for Mac (This tutorial will focus on XAMPP and Windows because that’s what I’m familiar with, but the steps should be near identical to MAMP/Mac).
They’re both free. Just download them, then use the GUI to start Apache and MySQL (or whatever else you need) to get started with your local test server and database.
You’ll of course put your test website’s files in a local folder, and XAMPP and MAMP needs to know the location of those files to function properly. Remember that folder’s location/directory address on your computer. If you’re using XAMPP, you have to change its config file in order for it to properly find your website folder, and thus, “host” those files locally. It should be in C:\XAMPP\apache\conf\httpd.conf or the Mac installation folder equivalent. Find the line that says ‘DocumentRoot’ as well as the line that says ‘Directory’ and change the default directories listed on those lines to your website folder’s directory. If you’re using MAMP, I don’t think you have to change the config file manually, but can instead change the destination folder directly on the control panel of MAMP’s GUI somewhere.
Now navigate to localhost on your browser to see if the root directory and folders show up. If you see your site folders/files, the emulated local server environment works.
Once you’re good to go, navigate to phpMyAdmin in your browser (or simply click the ‘Admin’ button beside ‘MySQL’ on the XAMPP GUI. It’s similar but different for MAMP). Click on the ‘Database’ tab and create a new database, calling it whatever you want (it’s probably best practice to name it after your website though).
Now the only thing left to do is tell your CMS core files about the database. In WordPress’s case, just edit wp-config, changing the placeholder ‘database_name_here’ line to your database’s name, and the user and password lines to the default settings (in Windows’ case: root and empty string ‘ ‘ respectively).
And that’s it. You’re all set.