I’m currently in the process of redesigning and reworking my art portfolio website. The website was built on WordPress, and I started it years ago before I ever really knew how to develop and design websites. As a result, the website has become a bit of a beast with all of its pages. So, when it comes to updating the overall look and feel, I’m often resistant to making updates since it often becomes a big ordeal.
However, the other day I realized it made more sense to figure out how to run my WordPress site locally to work on those updates in a dev environment. Previously I’d just copy the entire instance of the WordPress website and work on it live, then move the entire site to replace the older one. This always become a bit of an ordeal.
But now I’m excited at the possibilities of working locally before pushing those changes to the live environment. Here’s how I set up my environment:
- Download and install MAMP, which is software that installs a local server environment on your computer. MAMP gives you the ability to install Apache, PHP, and MySQL on your local machine. You can find out more about installing MAMP on the WordPress documentation website.
- Once MAMP is installed, you can copy over your entire website to your local machine.
- Open MAMP and specify the root of the folder for the site you want to run. Then start the servers.
- Next update the wp-config-php file so that it specifies the local host as the host, as opposed to the domain name:
define('DB_HOST', 'localhost');
- Then access the MAMP welcome screen and open up the local phpMyAdmin.
- Find the “create new database field” and enter in the name of the backup database from the live website that you are going to import.
- When you access the site in the browser, you should be able to see the homepage although all the other pages are probably broken. This is because you need to update the siteurl and home configurations.
- In phpMyAdmin, select the new database
- Select the “wp_options” table
- Search for “siteurl” within the “option_name” column
- Edit the “siteurl” so it points to the localhost
- Next, search for “home” within the “option_name” column
- Edit the “home” item so it points to the localhost as well
- Next, visit the homepage for the locally installed site and ta-da, it should work fine. You are also able to login with the wp-admin by using the usual admin credentials you use for the live website. Now you can edit themes, update plugins, and test out other features locally without worrying about breaking your live website.