I’ve been asked a few times for a few pointers on how to work on your WordPress Theme and development area in a “safe” environment, away from a live server.
In other words, you’d rather work do your development in a place where only you can see it and if you’re going to make any mistakes it won’t completely hose or take down your server! In other words you’re going to install a “local server” instead of work on one that’s readily available and viewable by the entire world.
Obviously this is a good thing as you don’t want all of you dirty laundry hanging out for people to just snicker at, right? So then the answer is quite simple: Install WordPress locally on your own computer (laptop, desktop)! It’s not too hard and I’ll show you how to do it very quickly.
Ready to become a “Pro”? Here we go:
For Starters… Mac or Windows?
First thing you’ll need is one of the applications to use, including WordPress. There are many choices but I’ve found that these apps have seen the most success especially with people trying it for the first time:
Download one of those and I’ll begin to walk you through the Mac-version of the process (both Windows and Mac experiences are very similar). You’ll just set WordPress aside for now but we’ll get there very soon.
1. Download and Install:
I’m going to click that Gray Elephant icon above and grab the free version. Once you download it (might take a few since it’s 200+ MBs) you’ll walk through the installation process. It’s straight-forward:
Just go ahead and agree with the install and you should see it extract and begin the installation process:
For the Mac version I’m dragging in the left folder for installation. For Windows you’ll walk more through their auto-installer:
And that’s it. Once it’s done it might just want to restart you computer (if you’re on Windows) or just reboot for fun.
2. Setup App and WordPress
Once you restart go ahead and boot up the application. It should automatically kick you into a browser so you can see the native settings and configurations that come standard through the application.
Please also note that it should kick in a little notice or dialogue window that actively shows that your local MAMP server is online and working. You should see both of these green lights on:
This is how you can also Stop and Start your local server at will. I’m not going to spend any time explaining MySQL or Apache in this tutorial, you can Google those and read more about them but I’m sure you’re already familiar if you’re attempting this local install in the first place!
Back to your browser, the most important thing is this area right here:
You’ll need this information to install WordPress successfully so don’t ditch that quite yet.
If you don’t see this browser window just go here:
Installing WordPress is your next step! Just find the MAMP folder in your finder (it should be in your “Applications” folder) and drag and drop all of the contents of the WordPress application into the htdocs folder:
What it should look like is this when I’ve copied over all the WordPress files:
Looks a bit familiar? For those that have been around WordPress you’ll notice all the files that you’d come to expect. No surprise here.
The next part is simply installing WordPress: Just head back to your browser and head to this address:
What you should see is the install screen:
Then you can walk through installing WordPress as you normally would. When you get to this screen just make sure you’re inputting the right information that MAMP (or your Windows app) is using natively.
As you can see I simply used the existing information that they provided me with:
- Database Name: mysql
- User Name: root
- Password: root
- Database Host: localhost
- Table Prefix: wp_
And that’s it! You should see the success screen as you walk through your local settings:
Ah, the sweet feeling of success! You should also get an email too if you added a real email address:
So, to visit your new locally installed blog all you have to do is head back to this address in your browser:
And there she is, a fresh install of WordPress:
3. Install WordPress Themes, Plugins
Obviously if you’re interested in doing this in the first place your aim is to do some local testing on a WordPress Theme or WordPress Plugin so that you don’t mess something royally on a live server.
If that’s the case then all you have to do is drag and drop any and all plugins and themes into the wp-content folder in your local system.
As you can see I’ve added those two folders into my htdocs folder under MAMP.
Now, when I login I should see them and be able to activate them on my local server:
And the plugin…
And when I check out my homepage and one of default posts I see not only the new WordPress Theme but also that the WordPress Plugin has activated successfully:
That was easy!
Now, you can go ahead and begin to do all your local work on your Theme, Plugins, and even create dummy content before you actually move it to a live server!
4. Migrating to a Live Server
An obvious next question is how to move it to a actual live server. This is an important step as you move from the local environment to the new one.
Now there are a lot of different and varying scenarios for the import process so I’ll keep it pretty generic here covering the obvious portions of the migration. For all other questions feel free to drop a comment below and I’ll see if I can help you!
The first thing you do is jump back into your MySQL database. You’ll have to head back to the browser and go to the URL of MAMP or your specific application. In my case it’s here:
You’ll see the link to phpMyAdmin which is the area where you manage your database. Click that link:
What you’ll now see is your actual database. What were going to do is export fully your WordPress database for use in the real and live environment.
Head over to the export tab:
The files that you want are specific to WordPress and if you kept the same prefix of wp_ then you’ll see them all here:
You’ll then want select the right ones here (or “All”):
And then you’ll want to save the file locally to your machine:
The file then should sit on your desktop!
Open up the file (should be named something like mysql.sql if you didn’t specify anything specifically) in a file editor.
You’ll put search for:
and replace it with:
Then save the file.
You’ll then want to copy over the contents of the htdocs folder into your new server. Try to keep the same folder structure as you did on your local machine. For example, if you installed locally to /wordpress then your live server should have it installed on /wordpress as well.
Copy over all files and then edit your wp-config.php file to the new database that you’ll create via your control panel. I’d highly suggest not using the default values that you were using locally!
Then you’ll head to your own phpMyAdmin in your hosting solution and import the mysql.sql file that you exported earlier:
And then hit the import tab like you did when you exported:
And that’s it!
With these changes you should be able to login to your new site that is live on a server and see what you’ve done locally!
Of course, the migration part as I mentioned previously is going to be a bit different depending on your settings and how you installed WordPress so feel free to ask questions.
For the most part though one of the better solutions than a full migration is simply working on the WordPress Themes and Plugins and just moving those files/folders instead of doing a full port every single time. This is much easier (obviously).
Migrate Live Site and Blog to Local Machine:
Have you ever wanted to try your hand at a new WordPress Theme, make the tweaks in a safe environment with real live data? Well that’s a good idea!
It’s quite easy to do: All you need to do is export your current and existing site via WordPress and then import into your local system. Go to Tools >> Explort >> All Content:
And then on your local WordPress installation you’ll just do Import >> Find File >> Next:
After that you should see all of your live content in your local machine!
See, I tested it on my local box and have a full one-to-one (1:1) blog import:
You can see it in the above screenshot that I’m in my “local” environment by the fact that I have this in the browser url:
Done and done!
That’s it! Take a new WordPress Theme for a spin and try it on real, live data so that you know exactly what you’re getting into!
Good luck and happy developing!